]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/TwitchBot.php
twitch chat bot controls
[alttp.git] / app / TwitchBot / TwitchBot.php
index 79b6bf13f1861af5bde63e400992cbc060e08ae0..bb3724d6844bbf7f0990f5306fb3f04069f834a3 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\TwitchBot;
 
 use App\Models\Channel;
+use App\Models\TwitchBotCommand;
 use App\Models\TwitchToken;
 use Monolog\Handler\StreamHandler;
 use Monolog\Logger;
@@ -169,6 +170,20 @@ class TwitchBot {
        }
 
 
+       protected function listenCommands() {
+               $this->getLoop()->addPeriodicTimer(1, function () {
+                       if (!$this->isReady()) return;
+                       $command = TwitchBotCommand::where('bot_nick', '=', $this->nick)->where('status', '=', 'pending')->oldest()->first();
+                       if ($command) {
+                               try {
+                                       $command->execute($this);
+                               } catch (\Exception $e) {
+                               }
+                       }
+               });
+       }
+
+
        private $logger;
 
        private $nick;