示例#1
0
文件: Channel.php 项目: nkreer/Fish
 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;
     }
 }
示例#2
0
文件: _376.php 项目: nkreer/Fish
 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
             }
         }
     }
 }
示例#3
0
文件: IRC.php 项目: nkreer/Fish
 /**
  * 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
     }
 }
示例#4
0
文件: User.php 项目: nkreer/Fish
 /**
  * @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;
 }