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 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';
return $this->command == 'PING';
}
+ public function isPong() {
+ return $this->command == 'PONG';
+ }
+
public function isPrivMsg() {
return $this->command == 'PRIVMSG';
}