]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/TwitchChatBot.php
twitch chat bot controls
[alttp.git] / app / TwitchBot / TwitchChatBot.php
index 0469fbc324ccf55abeb230bad13b009fd4aeb4bf..7a6eb1c1357cb9c59d12c2bfc9af81467383ae53 100644 (file)
@@ -20,6 +20,7 @@ class TwitchChatBot extends TwitchBot {
                        ];
                }
                $this->startTimer();
+               $this->listenCommands();
        }
 
        public function joinChannels() {
@@ -77,7 +78,15 @@ class TwitchChatBot extends TwitchBot {
        }
 
        private function randomMsg(Channel $channel) {
-               $line = ChatLog::where('type', '=', 'chat')->where('banned', '=', false)->inRandomOrder()->first();
+               $line = ChatLog::where('type', '=', 'chat')
+                       ->where('banned', '=', false)
+                       ->where('created_at', '<', now()->sub(1, 'day'))
+                       ->where(function ($query) use ($channel) {
+                               $query->whereNull('detected_language');
+                               $query->orWhereIn('detected_language', $channel->languages);
+                       })
+                       ->inRandomOrder()
+                       ->first();
                return $line->text_content;
        }
 
@@ -86,7 +95,7 @@ class TwitchChatBot extends TwitchBot {
        }
 
        private function randomWaitTime(Channel $channel) {
-               return random_int(1, 1800);
+               return random_int(1, 900);
        }
 
        private function tagChannelRead(Channel $channel) {