コード例 #1
0
 public static function destroy()
 {
     if (!empty(IRCServerChannel::$channels)) {
         foreach (IRCServerChannel::$channels as $channel) {
             $channel->online = FALSE;
             $channel->server = NULL;
         }
     }
     if (self::$server_connection->connected) {
         debug_print_backtrace();
         self::$server_connection->send_immediate('QUIT :Fatal Error');
     }
     self::$server_connection->connected = FALSE;
     self::$server_connection->online = FALSE;
     self::$server_connection = NULL;
 }
コード例 #2
0
 /**
  * Called every 10 seconds when the bot is online but not in the channel
  */
 public function autojoin()
 {
     $this->server->send_line("JOIN {$this->channel}");
 }
コード例 #3
0
 /**
  * Creates a new outbound buffer resource and connects to the server
  * 
  * @param String Server to connect to
  * @param String Port to connect to
  * @param String Nickname to use
  * @param Array List of channels to join
  */
 public function __construct($server, $port, $nickname, $channels, $debug = FALSE)
 {
     if (!empty(self::$server_connection) && self::$server_connection->connected) {
         $this->online = FALSE;
         $this->connected = FALSE;
         throw new IRCServerException('You cannot connect to more than one server at a time!');
     }
     set_time_limit(0);
     register_shutdown_function(array('IRCServerConnection', 'destroy'));
     $this->buffer = array();
     $this->server = $server;
     $this->port = $port;
     $this->nick = $nickname;
     $this->debug = $debug;
     self::$server_connection = $this;
     try {
         $this->connect($channels);
     } catch (IRCServerException $e) {
         $this->online = FALSE;
         $this->connected = FALSE;
         throw $e;
     }
 }
コード例 #4
0
 /**
  * Kick a person from the channel
  *
  * @param String Nickname of the user to kick
  * @param String Reason to give
  */
 public function kick_user($nick, $message)
 {
     $this->server->send_line("KICK {$this->channel} {$nick} :{$message}");
 }