- if ($target[0] != '#') return;
- $text = $msg->getText();
- if ($text[0] != '!') return;
- $channel = Channel::firstWhere('twitch_chat', '=', $target);
- if (!$channel) return;
- $this->handleChatCommand($channel, $msg);
- }
-
- public function handleChatCommand(Channel $channel, IRCMessage $msg) {
- $cmd = explode(' ', ltrim($msg->getText(), '!'), 2);
- if (!isset($channel->chat_commands[$cmd[0]])) return;
- $config = $channel->chat_commands[$cmd[0]];
- $this->logger->info('got command '.$cmd[0].' on channel '.$channel->title);
- try {
- $command = ChatCommand::create($this, $channel, $config);
- $command->execute($cmd[1] ?? '');
- } catch (\Exception $e) {
- $this->logger->warning('error executing command '.$cmd[0].' on channel '.$channel->title.': '.$e->getMessage());
+ if (substr($target, 0, 1) !== '#') {
+ $target = '#'.$target;
+ }
+ return Channel::firstWhere('twitch_chat', '=', $target);
+ }
+
+ public function logMessage(IRCMessage $msg) {
+ }
+
+ public function handlePrivMsg(IRCMessage $msg) {
+ }
+
+ public function handleUserState(IRCMessage $msg) {
+ if (isset($msg->tags['user-id'])) {
+ $this->user_id = $msg->tags['user-id'];