From aff6a3e616b822dc6bff00b8b4acfee8b33f19a0 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 23 Mar 2024 20:47:09 +0100 Subject: [PATCH] slightly better chat bot msg selection --- app/TwitchBot/TwitchChatBot.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/TwitchBot/TwitchChatBot.php b/app/TwitchBot/TwitchChatBot.php index a3ffe2d..f43dba7 100644 --- a/app/TwitchBot/TwitchChatBot.php +++ b/app/TwitchBot/TwitchChatBot.php @@ -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 (!$msg->isKnownBot() && !$msg->scanForSpam()) { + $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']); + } } } -- 2.39.2