}
public function randomOfClass($class) {
- $line = $this->queryChatlog()
+ if (is_array($class)) {
+ return $this->queryChatlog()
+ ->whereIn('classification', $class)
+ ->first();
+ }
+ return $this->queryChatlog()
->where('classification', '=', $class)
->first();
- return $line ? $line->text_content : '';
}
public function queryChatlog() {
- return ChatLog::where('type', '=', 'chat')
+ $min_age = $this->getChatSetting('min_age', 1);
+ $query = ChatLog::where('type', '=', 'chat')
->where('banned', '=', false)
- ->where('created_at', '<', now()->sub(1, 'day'))
+ ->where('created_at', '<', now()->sub($min_age, 'day'))
->where(function ($query) {
$query->whereNull('detected_language');
$query->orWhereIn('detected_language', $this->getPreferredLanguages());
})
->inRandomOrder();
+ $source = $this->getChatSetting('source', 'any');
+ if (in_array($source, ['catchan', 'chan'])) {
+ $query->where('channel_id', $this->id);
+ }
+ if (in_array($source, ['cat', 'catchan'])) {
+ $query->where('twitch_category', $this->twitch_category);
+ }
+ return $query;
}
public function getPreferredLanguages() {
$transformed = $this->transformGuess($solution);
if ($this->guessing_type == 'gtbk') {
$int_solution = intval($transformed);
- return is_numeric($transformed) && $int_solution > 0 && $int_solution < 23;
+ return is_numeric($transformed) && $int_solution >= 0 && $int_solution <= 23;
}
return false;
}
return Arr::join($entries, ', ', ' and ');
}
+ public function chat_bot_logs() {
+ return $this->hasMany(ChatBotLog::class);
+ }
+
public function crews() {
return $this->hasMany(ChannelCrew::class);
}