/** * Removes the bot from given channel * @param string $channel */ public function part($channel, $message = "Leaving") { // join channel Services::getConnection()->getProtocol()->part($this->getUuid(), $channel, $message); // notify channel manager $chan = Services::getChannelManager()->getChannel($channel); $chan->part($this->getUuid()); }
/** * @see lib/modules/CommandModule::execute() */ public function execute($user, $target, $message) { // split message $messageEx = explode(' ', $message); if ($target[0] != '#') { $target = $messageEx[1]; unset($messageEx[1]); $messageEx = array_values($messageEx); } if ($this->bot->isRegistered($target)) { return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.alreadyRegistered')); } $users = Services::getChannelManager()->getChannel($target)->getUserList(); foreach ($users as $channelUser) { if ($channelUser['user']->getUuid() == $user->getUuid()) { if (stripos($channelUser['mode'], 'o')) { $this->bot->register($target, Services::getUserManager()->getUser($user->getUuid())->accountname); Services::getConnection()->getProtocol()->sendMode($this->bot->getUuid(), $target, '+q ' . $user->getNick()); return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success', $target)); } } } return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.noOp')); }
/** * Handles PART command * * @param string $input * @param array<string> $inputEx * @return void */ public static function PART($input, $inputEx) { Services::getEvent()->fire(Services::getConnection()->getProtocol(), 'userParted', array('channel' => $inputEx[2], 'user' => Services::getUserManager()->getUser($inputEx[0]))); Services::getChannelManager()->getChannel($inputEx[2])->part($inputEx[0]); }
/** * Notifies bots if a new messages received * @param UserType $user * @param string $target * @param string $message */ public function handleLine($user, $target, $message) { if ($target[0] != '#') { foreach ($this->runningBots as $key => $bot) { if ($this->runningBots[$key]->getBot()->getUuid() == $target) { $this->runningBots[$key]->handleLine($user, $target, $message); } } } else { $trigger = $message[0]; $message = substr($message, 1); foreach ($this->runningBots as $key => $bot) { if (strtolower($this->runningBots[$key]->getTrigger()) == strtolower($trigger) and Services::getChannelManager()->getChannel($target)->isJoined($this->runningBots[$key]->getUuid())) { $this->runningBots[$key]->handleLine($user, $target, $message); } } } }