X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FTwitchBot%2FTwitchBot.php;fp=app%2FTwitchBot%2FTwitchBot.php;h=bb3724d6844bbf7f0990f5306fb3f04069f834a3;hb=06fbdc15c8db57590c9b6a38ee1f00d5f349cff9;hp=79b6bf13f1861af5bde63e400992cbc060e08ae0;hpb=cce68689529251915af11ade10699ffa74cb6a3b;p=alttp.git diff --git a/app/TwitchBot/TwitchBot.php b/app/TwitchBot/TwitchBot.php index 79b6bf1..bb3724d 100644 --- a/app/TwitchBot/TwitchBot.php +++ b/app/TwitchBot/TwitchBot.php @@ -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;