]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/IRCMessage.php
log irc messages
[alttp.git] / app / TwitchBot / IRCMessage.php
index c730ef7d0bfa962126417f7b513e7adc46984b9b..1e64bd9b6de7c12c0674ce7966e06adbd914f0b0 100644 (file)
@@ -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';
@@ -139,6 +150,13 @@ class IRCMessage {
                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';
@@ -169,6 +187,10 @@ class IRCMessage {
                return $this->command == 'PING';
        }
 
+       public function isPong() {
+               return $this->command == 'PONG';
+       }
+
        public function isPrivMsg() {
                return $this->command == 'PRIVMSG';
        }