namespace App\TwitchBot;
use App\Models\Channel;
+use App\Models\TwitchBotCommand;
use App\Models\TwitchToken;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
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) {
}
});
}
+ 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;