X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FTwitchBot%2FIRCMessage.php;h=b986847792f6898a4d99f8abb9a82f9455e55318;hb=HEAD;hp=89aa023a1230c2ca74ba108c315a72a8d5b88434;hpb=e5192dadab765ecf0cdb877e0497293e0c9f1e45;p=alttp.git diff --git a/app/TwitchBot/IRCMessage.php b/app/TwitchBot/IRCMessage.php index 89aa023..b986847 100644 --- a/app/TwitchBot/IRCMessage.php +++ b/app/TwitchBot/IRCMessage.php @@ -35,7 +35,7 @@ class IRCMessage { $has_host = false; $prefix = explode(' ', $processed, 2); $processed = $prefix[1]; - $prefix = ltrim($prefix[0], ':'); + $prefix = $prefix[0][0] === ':' ? substr($prefix[0], 1) : $prefix[0]; if (strpos($prefix, '!') !== false) { $has_user = true; } @@ -67,7 +67,7 @@ class IRCMessage { while (strlen($processed)) { if ($processed[0] == ':') { - $msg->params[] = ltrim($processed, ':'); + $msg->params[] = substr($processed, 1); break; } $e = explode(' ', $processed, 2); @@ -136,6 +136,17 @@ class IRCMessage { ]); } + public function tokenize() { + return TokenizedMessage::fromIRC($this); + } + + public static function capReq($cap) { + $msg = new IRCMessage(); + $msg->command = 'CAP REQ'; + $msg->params[] = $cap; + return $msg; + } + public static function join($channels) { $msg = new IRCMessage(); $msg->command = 'JOIN'; @@ -195,6 +206,10 @@ class IRCMessage { return $this->command == 'PRIVMSG'; } + public function isWhisper() { + return $this->command == 'WHISPER'; + } + public function isOwner() { return substr($this->getPrivMsgTarget(), 1) == $this->nick; }