X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FTwitchBot%2FTwitchBot.php;h=e5a5aa6e442307b06bbae8b68635a07f4255b463;hb=c66d9d3c5eda563842c683827da1abf445b65483;hp=79b6bf13f1861af5bde63e400992cbc060e08ae0;hpb=85879ea0c27ce6506919e2c083a139c470c0952c;p=alttp.git diff --git a/app/TwitchBot/TwitchBot.php b/app/TwitchBot/TwitchBot.php index 79b6bf1..e5a5aa6 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; @@ -155,7 +156,7 @@ class TwitchBot { if (!$this->ready) return; if (time() - $this->last_contact < 60) return; try { - $this->sendIRCMessage(IRCMessage::ping()); + $this->sendIRCMessage(IRCMessage::ping($this->nick)); } catch (\Exception $e) { } }); @@ -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;