protected function run(array $args, Session $sender) { if (!isset($args[0])) { switch ($sender->getCurrentChatState()) { case Session::CHANNEL_LOCAL: $sender->send(Phrases::CMD_CHANNEL_VIEW_LOCAL); break; case Session::CHANNEL_TEAM: $sender->send(Phrases::CMD_CHANNEL_VIEW_TEAM); break; default: $sender->send(Phrases::CMD_CHANNEL_VIEW_OTHER, ["chan" => $sender->getCurrentChatState()]); } return $sender->translate(Phrases::CMD_CHANNEL_VIEW_SUBSCRIBING_TO_CHANNELS, ["channels" => implode(", ", $sender->getChannelSubscriptions())]); } $name = array_shift($args); if (strtolower($name) === "local" or strtolower($name) === "g" or strtolower($name) === "l") { $sender->setCurrentChatState(Session::CHANNEL_LOCAL); return $sender->translate(Phrases::CMD_CHANNEL_SET_LOCAL); } elseif (strtolower($name) === "team" or strtolower($name) === "t") { if ($sender->getTeamId() === -1) { return $sender->translate(Phrases::CMD_TEAM_ERR_NOT_IN_TEAM); } $sender->setCurrentChatState(Session::CHANNEL_TEAM); return $sender->translate(Phrases::CMD_CHANNEL_SET_TEAM); } elseif (strtolower($name) === "quit") { if (!isset($args[0])) { return false; } $ch = array_shift($args); if (!$sender->isOnChannel($ch)) { return $sender->translate(Phrases::CMD_CHANNEL_QUIT_NOT_ON_CHANNEL); } $sender->partChannel($ch); return $sender->translate(Phrases::CMD_CHANNEL_QUIT_SUCCESS); } else { if (!$sender->isOnChannel($name)) { $sender->joinChannel($name); $sender->send(Phrases::CMD_CHANNEL_JOINED_SELF, ["channel" => $name]); } $sender->setCurrentChatState($name); return $sender->translate(Phrases::CMD_CHANNEL_SET_OTHER, ["chan" => $name]); } }