]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/IRCMessage.php
simple guessing game
[alttp.git] / app / TwitchBot / IRCMessage.php
index d127f9f5d57425e850512640d6ae470c2f0c1bc3..4fb54c670b7a8890e89af029f6dc9b649efb42cc 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';
@@ -184,6 +195,14 @@ class IRCMessage {
                return $this->command == 'PRIVMSG';
        }
 
+       public function isOwner() {
+               return substr($this->getPrivMsgTarget(), 1) == $this->nick;
+       }
+
+       public function isMod() {
+               return $this->isOwner() || (isset($this->tags['mod']) && $this->tags['mod'] = '1');
+       }
+
        public function makePong() {
                $msg = new IRCMessage();
                $msg->command = 'PONG';