X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FTwitchBot%2FTwitchChatBot.php;h=cb390f9655a863d21217c424d2b7672ae1c8d1c5;hb=abdc2ea1ade1fb12ceacc28660890750e69ae36f;hp=8aac9d70bd66652eee0edad17161007732ad0586;hpb=cb9234cb76d8f7509e9280b8cd7d63180acf2ba0;p=alttp.git diff --git a/app/TwitchBot/TwitchChatBot.php b/app/TwitchBot/TwitchChatBot.php index 8aac9d7..cb390f9 100644 --- a/app/TwitchBot/TwitchChatBot.php +++ b/app/TwitchBot/TwitchChatBot.php @@ -72,7 +72,7 @@ class TwitchChatBot extends TwitchBot { return; } $text = $this->contextualMsg($channel); - if (!$text) $text = $this->randomMsg($channel); + if (!$text) $text = $this->randomChat($channel); if (!$text) return; $this->tagChannelWrite($channel); $this->sendIRCMessage(IRCMessage::privmsg($channel->twitch_chat, $text)); @@ -190,6 +190,17 @@ class TwitchChatBot extends TwitchBot { return $pogs > 2; } + private function checkForSalute(Channel $channel) { + $notes = $this->getNotes($channel); + $o7s = 0; + foreach ($notes['latest_msgs'] as $text) { + if (ChatLog::classify($text) == 'o7') { + ++$o7s; + } + } + return $o7s > 2; + } + private function contextualMsg(Channel $channel) { $last = $this->getNote($channel, 'last_special'); if ($last != 'gg' && $this->checkForGG($channel)) { @@ -220,6 +231,10 @@ class TwitchChatBot extends TwitchBot { $this->setNote($channel, 'last_special', 'pog'); return $this->randomOfClass($channel, 'pog'); } + if ($last != 'o7' && $this->checkForSalute($channel)) { + $this->setNote($channel, 'last_special', 'o7'); + return $this->randomOfClass($channel, 'o7'); + } return false; } @@ -234,6 +249,13 @@ class TwitchChatBot extends TwitchBot { ->inRandomOrder(); } + private function randomChat(Channel $channel) { + $line = $this->queryChatlog($channel) + ->whereIn('classification', ['hi', 'hype', 'lol', 'pog', 'unclassified']) + ->first(); + return $line->text_content; + } + private function randomContextualNumber(Channel $channel) { $notes = $this->getNotes($channel); $min = 100000; @@ -310,9 +332,11 @@ class TwitchChatBot extends TwitchBot { $this->getNotes($channel); $this->notes[$channel->id]['last_read'] = time(); ++$this->notes[$channel->id]['read_since_last_write']; - $this->notes[$channel->id]['latest_msgs'][] = $msg->getText(); - if (count($this->notes[$channel->id]['latest_msgs']) > 10) { - array_shift($this->notes[$channel->id]['latest_msgs']); + if (!ChatLog::isKnownBot($msg->nick) && !ChatLog::spammyText($msg->getText())) { + $this->notes[$channel->id]['latest_msgs'][] = $msg->getText(); + if (count($this->notes[$channel->id]['latest_msgs']) > 10) { + array_shift($this->notes[$channel->id]['latest_msgs']); + } } }