Exemple #1
0
 public static function run(Command $command, Connection $connection, JsonConfig $config)
 {
     $channelName = $command->getArg(1);
     $userCount = $command->getArg(2);
     $args = $command->getArgs();
     $topic = explode(":", implode(" ", $args), 2)[1];
     $event = new ChannelListEvent($channelName, $userCount, $topic);
     $connection->getEventHandler()->callEvent($event);
 }
Exemple #2
0
 public static function run(Command $command, Connection $connection, JsonConfig $config)
 {
     $ev = new PingEvent();
     $connection->getEventHandler()->callEvent($ev);
     $ev = new PongEvent();
     $connection->getEventHandler()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $connection->lastPing = time();
         $connection->sendData("PONG " . $command->getArgs()[0]);
         //Reply to Pings
     }
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 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);
 }
Exemple #5
0
 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);
         }
     }
 }
Exemple #6
0
 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
     }
 }
Exemple #7
0
 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));
 }