]> git.localhorst.tv Git - alttp.git/commitdiff
salute classification
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 21 Feb 2024 11:47:59 +0000 (12:47 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 21 Feb 2024 11:47:59 +0000 (12:47 +0100)
app/Models/ChatLog.php
app/TwitchBot/TwitchChatBot.php

index 1f0663ccac02d6bcbe5950156e2198b4b6ee594f..1da62d5af27e3debbd967d735cf3f349d4b301ad 100644 (file)
@@ -95,6 +95,9 @@ class ChatLog extends Model {
                if (Str::contains($rawText, ['hype'])) {
                        return 'hype';
                }
+               if (Str::startsWith($rawText, 'o7') || Str::endsWith($rawText, 'o7') || Str::contains($rawText, 'salut')) {
+                       return 'o7';
+               }
                return 'unclassified';
        }
 
index 8aac9d70bd66652eee0edad17161007732ad0586..a3ffe2dbed0970ef60a29080b718b205dcfc0287 100644 (file)
@@ -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;
        }