X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FTwitchBot%2FIRCMessage.php;h=1e64bd9b6de7c12c0674ce7966e06adbd914f0b0;hb=c85a9e1de80d4a68e9b1b730e60906475682455b;hp=00217dc044660b1a5b70c471a8f20497e611fad1;hpb=cde5d79cf2f09d61fa7b181cd3a1a19050a4aeb3;p=alttp.git diff --git a/app/TwitchBot/IRCMessage.php b/app/TwitchBot/IRCMessage.php index 00217dc..1e64bd9 100644 --- a/app/TwitchBot/IRCMessage.php +++ b/app/TwitchBot/IRCMessage.php @@ -2,6 +2,8 @@ namespace App\TwitchBot; +use App\Models\ChatLog; + class IRCMessage { public $command = null; @@ -125,6 +127,15 @@ class IRCMessage { return $str; } + public function log() { + ChatLog::create([ + 'command' => $this->command, + 'nick' => $this->nick, + 'params' => $this->params, + 'tags' => $this->tags, + ]); + } + public static function join($channels) { $msg = new IRCMessage(); $msg->command = 'JOIN'; @@ -132,6 +143,20 @@ class IRCMessage { return $msg; } + public static function part($channels) { + $msg = new IRCMessage(); + $msg->command = 'PART'; + $msg->params[] = implode(',', $channels); + return $msg; + } + + public static function ping($token = 'localhorsttv') { + $msg = new IRCMessage(); + $msg->command = 'PING'; + $msg->params[] = $token; + return $msg; + } + public static function privmsg($target, $message) { $msg = new IRCMessage(); $msg->command = 'PRIVMSG'; @@ -162,6 +187,10 @@ class IRCMessage { return $this->command == 'PING'; } + public function isPong() { + return $this->command == 'PONG'; + } + public function isPrivMsg() { return $this->command == 'PRIVMSG'; }