public static function run(Command $command, Connection $connection, JsonConfig $config) { $args = $command->getArgs(); $channel = Channel::getChannel($connection, $args[1]); for ($a = 0; $a <= 1; $a++) { unset($args[$a]); } $topic = explode(":", implode(" ", $args), 2)[1]; $channel->topic = $topic; $ev = new TopicReceiveEvent($topic, $channel); $connection->getEventHandler()->callEvent($ev); }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $channel = Channel::getChannel($connection, $command->getArg(0)); $user = User::getUser($connection, $command->getPrefix()); $args = $command->getArgs(); for ($a = 0; $a <= 0; $a++) { unset($args[$a]); } $topic = explode(":", implode(" ", $args), 2)[1]; $ev = new TopicChangeEvent($topic, $channel, $user); $connection->getEventHandler()->callEvent($ev); }
public function onCommand(CommandInterface $command, CommandSender $sender, CommandSender $room, array $args) { $channels = explode(",", $args[1]); if (!empty($channels)) { foreach ($channels as $channel) { $channel = Channel::getChannel($this->connection, $channel); $this->connection->partChannel($channel); } $sender->sendNotice("Parted channel(s): " . implode(", ", $channels)); return true; } return false; }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $user = User::getUser($connection, $command->getPrefix()); $arg = $command->getArgs(); if ($command->getArg(0) === $connection->nickname) { $channel = Channel::getChannel($connection, $user->getNick()); } else { $channel = Channel::getChannel($connection, $arg[0]); } unset($arg[0]); $args = explode(":", implode(" ", $arg), 2); if ($args[1][0] === chr(1)) { //Check whether the message is a ctcp, message or command $args[1] = explode(" ", $args[1], 2); $ctcp_command = str_replace(chr(1), "", $args[1][0]); unset($args[1][0]); $ev = new CTCPReceiveEvent($user, $ctcp_command); $connection->getEventHandler()->callEvent($ev); if (empty($args[1][1])) { if ($reply = IRC::getInstance()->getConfig()->getData("default_ctcp_replies", [])[$ctcp_command]) { if ($reply !== null) { $ev = new CTCPSendEvent($user, $ctcp_command, $reply); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { $user->sendNotice(chr(1) . $ctcp_command . " " . $ev->getMessage()); } } } } } elseif (!in_array($args[1][0], $config->getData("command_prefix", [".", "!", "\\", "@"]))) { $ev = new MessageReceiveEvent($args[1], $user, $channel); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { Logger::info(BashColor::GREEN . $ev->getChannel()->getName() . " " . $ev->getUser()->getNick() . ":" . BashColor::REMOVE . " " . $ev->getMessage()); //Display the message to the console } } else { $args[1] = substr($args[1], 1); $args[1] = explode(" ", $args[1]); $cmd = strtolower($args[1][0]); //Command in lower case unset($args[1][0]); Logger::info(BashColor::CYAN . $user->getNick() . " > " . $cmd . " " . implode(" ", $args[1])); $ev = new CommandEvent($cmd, $args[1], $channel, $user); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { $connection->getCommandHandler()->handleCommand($cmd, $user, $channel, $args); } } }
public static function run(Command $command, Connection $connection, JsonConfig $config) { //Tell the plugins that a user has parted $channel = Channel::getChannel($connection, str_replace(":", "", $command->getArg(0))); $user = User::getUser($connection, $command->getPrefix()); if ($user instanceof User) { $ev = new ChannelLeaveEvent($channel, $user); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { Logger::info($user->getNick() . " left " . $channel->getName()); User::removeUser($connection, $user->getHostmask()); //Remove the user, don't care if they are in other channels the bot is in } } }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $user = User::getUser($connection, $command->getPrefix()); $arg = $command->getArgs(); if ($command->getArg(0) === $connection->nickname) { $channel = Channel::getChannel($connection, $user->getNick()); } else { $channel = Channel::getChannel($connection, $arg[0]); } unset($arg[0]); $ev = new NoticeReceiveEvent(explode(":", implode(" ", $arg), 2)[1], $user, $channel); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { Logger::info(BashColor::HIGHLIGHT . (!empty($ev->getUser()->getNick()) ? $ev->getUser()->getNick() . ": " : " ") . $ev->getNotice() . BashColor::REMOVE); //Display the notice to the console } }
public static function run(Command $command, Connection $connection, JsonConfig $config) { //Tell the plugins that a user was kicked $channel = Channel::getChannel($connection, str_replace(":", "", $command->getArg(0))); $kicker = User::getUser($connection, $command->getPrefix()); $user = $command->getArg(1); $ev = new KickEvent($user, $channel, $kicker); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { Logger::info($user . " was kicked from " . $channel->getName()); if ($user === $connection->getNick()) { if (IRC::getInstance()->getConfig()->getData("auto_rejoin_after_kick", false)) { // Make the bot rejoin in 5 seconds $connection->getScheduler()->scheduleDelayedTask(new RejoinChannelTask($connection, $channel), 5); } } } }
public static function run(Command $command, Connection $connection, JsonConfig $config) { //Tell the plugins that a user has joined $channel = Channel::getChannel($connection, str_replace(":", "", $command->getArg(0))); $user = User::getUser($connection, $command->getPrefix()); if ($user->getNick() === $connection->getNick()) { $ev = new BotJoinChannelEvent($channel, $user); } else { $ev = new JoinChannelEvent($channel, $user); } $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { Logger::info($user->getNick() . " joined " . $channel->getName()); if ($ev instanceof BotJoinChannelEvent) { $connection->addChannel($channel); // Add the channel } } }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $ev = new ConnectionFinishedEvent($connection); $connection->getEventHandler()->callEvent($ev); if (!$ev->isCancelled()) { $config = IRC::getInstance()->getConfig()->getData("connections"); if (!empty($config[$connection->getAddress()]["nickserv"])) { $connection->getNickServ()->identify($config[$connection->getAddress()]["nickserv"]); //Identify with NickServ } if (!empty($config[$connection->getAddress()]["channels"])) { $channels = $config[$connection->getAddress()]["channels"]; foreach ($channels as $channel) { $connection->joinChannel(Channel::getChannel($connection, $channel)); //Join these channels } } } }
public function onCommand(CommandInterface $command, CommandSender $sender, CommandSender $room, array $args) { if (!empty($args[1])) { $channel = Channel::getChannel($this->connection, $args[1]); unset($args[1]); $text = implode(" ", $args); if (!empty($text)) { if ($text[0] === "*") { $channel->sendAction(str_replace("*", "", $text)); } else { $channel->sendMessage($text); } $sender->sendNotice("Message sent."); } else { $sender->sendNotice("No text to say"); } } else { $sender->sendNotice("Argument 1 must be a channel"); } }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $user = User::getUser($connection, $command->getPrefix()); $channel = Channel::getChannel($connection, $command->getArg(0)); $mode = $command->getArg(1); if ($channel->getName() === $connection->getNick()) { $ev = new MyModesChangeEvent($mode, $user, $channel); $connection->getEventHandler()->callEvent($ev); } elseif (empty($command->getArg(2))) { if ($mode === "+b") { $ev = new BanSetEvent($command->getArg(1), $user, $channel); } elseif ($mode === "-b") { $ev = new UnbanEvent($command->getArg(1), $user, $channel); } else { $ev = new ChannelModeChangeEvent($mode, $user, $channel); } $connection->getEventHandler()->callEvent($ev); } else { $nick = $command->getArg(2); $ev = new UserModeChangeEvent($mode, $user, $channel, $nick); $connection->getEventHandler()->callEvent($ev); } }
/** * @param Channel $channel * @return bool */ public function isInChannel(Channel $channel) { return isset($this->channels[$channel->getName()]); }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $channel = Channel::getChannel($connection, explode(":", implode(" ", $command->getArgs()), 2)[1]); $user = User::getUser($connection, $command->getPrefix()); $connection->getEventHandler()->callEvent(new InvitationReceiveEvent($channel, $user)); }
/** * @param Channel $channel * @param String $mode */ public function takeMode(Channel $channel, string $mode) { $this->connection->sendData("MODE " . $channel->getName() . " -" . $mode . " " . $this->getNick()); }
public static function run(Command $command, Connection $connection, JsonConfig $config) { $channel = Channel::getChannel($connection, $command->getArg(1)); $time = $command->getArg(3); $channel->topicTime = $time; }