Пример #1
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
     }
 }
Пример #2
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);
 }
Пример #3
0
 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
             }
         }
     }
 }
Пример #4
0
 public function getEventHandler() : EventHandler
 {
     return $this->connection->getEventHandler();
 }
Пример #5
0
 public function handle(Command $run, Connection $connection)
 {
     $ev = new ConnectionActivityEvent($connection, $run);
     $connection->getEventHandler()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $command = $run->getCommand();
         if (is_numeric($command)) {
             $command = "_" . $command;
         }
         $function = '\\IRC\\Protocol\\' . strtoupper($command);
         if (method_exists($function, "run")) {
             // Most stupid hack ever, but it gets the job done
             call_user_func($function . "::run", $run, $connection, $this->getConfig());
         } else {
             // Handle unknown commands
             $unknownEvent = new ConnectionUnknownCommandEvent($connection, $run);
             $connection->getEventHandler()->callEvent($unknownEvent);
         }
     }
 }