]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/TwitchChatBot.php
better chat filters
[alttp.git] / app / TwitchBot / TwitchChatBot.php
index a3ffe2dbed0970ef60a29080b718b205dcfc0287..cb390f9655a863d21217c424d2b7672ae1c8d1c5 100644 (file)
@@ -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));
@@ -249,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;
@@ -325,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']);
+                       }
                }
        }