public static function getChannel(Connection $connection, string $name) { if (isset(self::$channels[$connection->getAddress()][$name])) { return self::$channels[$connection->getAddress()][$name]; } else { $channel = new Channel($connection, $name); self::$channels[$connection->getAddress()][$name] = $channel; return $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 } } } }
/** * Close a connection * @param Connection $connection * @param String $quitMessage * @return bool */ public function removeConnection(Connection $connection, string $quitMessage = null) : bool { if ($this->isConnected($connection->getAddress())) { Logger::info(BashColor::RED . "Disconnecting " . $connection->getAddress() . ":" . $connection->getPort()); if ($quitMessage === null) { $quitMessage = $this->config->getData("default_quitmsg", "Leaving"); } $connection->disconnect($quitMessage); unset($this->connections[$connection->getAddress()]); return true; } else { unset($this->connections[$connection->getAddress()]); return true; //These statements are kept for reasons of backwards-compatibility } }
/** * @param Connection $connection * @param $name * @return bool */ public static function removeUser(Connection $connection, $name) { if (isset(self::$users[$connection->getAddress()][$name])) { unset(self::$users[$connection->getAddress()][$name]); return true; } return false; }