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 } }
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); }
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 getEventHandler() : EventHandler { return $this->connection->getEventHandler(); }
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); } } }