namespace App\TwitchBot;
+use App\Models\ChatLog;
+
class IRCMessage {
public $command = null;
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';
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';
return $this->command == 'PING';
}
+ public function isPong() {
+ return $this->command == 'PONG';
+ }
+
public function isPrivMsg() {
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';