namespace App\TwitchBot;
use App\Models\Channel;
+use App\Models\ChatBotLog;
use App\Models\ChatLog;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
$text = $this->contextualMsg($channel);
if (!$text) $text = $this->randomChat($channel);
if (!$text) return;
+ $actual_text = is_object($text) ? $text->text_content : $text;
$this->tagChannelWrite($channel);
- $this->sendIRCMessage(IRCMessage::privmsg($channel->twitch_chat, $text));
+ $this->sendIRCMessage(IRCMessage::privmsg($channel->twitch_chat, $actual_text));
+ $log = new ChatBotLog();
+ $log->channel()->associate($channel);
+ if (is_object($text)) {
+ $log->origin()->associate($text);
+ }
+ $log->text = $actual_text;
+ $log->save();
}
private function getNotes(Channel $channel) {
}
private function randomChat(Channel $channel) {
- $line = $channel->queryChatlog()
+ return $channel->queryChatlog()
->whereIn('classification', ['hi', 'hype', 'lol', 'pog', 'unclassified'])
->first();
- return $line->text_content;
}
private function randomContextualNumber(Channel $channel) {
}
private function randomMsg(Channel $channel) {
- $line = $channel->queryChatlog()->first();
- return $line->text_content;
+ return $channel->queryChatlog()->first();
}
private function randomWaitMsgs(Channel $channel) {