libirc.php
changeset 51 508400fc5282
parent 40 1855846cbdab
equal deleted inserted replaced
50:45164bc2567a 51:508400fc5282
   251     foreach ( $message as $line )
   251     foreach ( $message as $line )
   252     {
   252     {
   253       $line = $this->filter_message($line);
   253       $line = $this->filter_message($line);
   254       $this->put("NOTICE $nick :$line\r\n");
   254       $this->put("NOTICE $nick :$line\r\n");
   255     }
   255     }
       
   256   }
       
   257   
       
   258   /**
       
   259    * Returns WHOIS information about a nick.
       
   260    * @param string Nick
       
   261    * @return array
       
   262    */
       
   263   
       
   264   public function whois($nick)
       
   265   {
       
   266     static $cache = array();
       
   267     if ( isset($cache[$nick]) )
       
   268     {
       
   269       if ( $cache[$nick]['time'] + 20 >= time() )
       
   270       {
       
   271         return $cache[$nick];
       
   272       }
       
   273     }
       
   274     $this->put("WHOIS $nick\r\n");
       
   275     $lines = array();
       
   276     $return = array(
       
   277         'identified' => false,
       
   278         'time' => time()
       
   279       );
       
   280     while ( $line = $this->get(3) )
       
   281     {
       
   282       $lines[] = $line;
       
   283       list(, $code) = explode(' ', $line);
       
   284       $code = intval($code);
       
   285       switch($code)
       
   286       {
       
   287         case 401:
       
   288           return false;
       
   289         case 311:
       
   290           list(, , , $return['nick'], $return['user'], $return['host']) = explode(' ', $line);
       
   291           $return['ircname'] = substr($line, strpos(substr($line, 1), ':') + 2);
       
   292           break;
       
   293         case 319:
       
   294           $return['channels'] = explode(' ', substr($line, strpos(substr($line, 1), ':') + 2));
       
   295           break;
       
   296         case 307:
       
   297         case 320:
       
   298           if ( strstr($line, 'identified') )
       
   299             $return['identified'] = true;
       
   300           break;
       
   301         case 318:
       
   302           $cache[$nick] = $return;
       
   303           return $return;
       
   304       }
       
   305     }
       
   306     $cache[$nick] = $return;
       
   307     return $return;
   256   }
   308   }
   257   
   309   
   258   /**
   310   /**
   259    * Parse bold (<b>...</b>) tags and color tags in a text into IRC speak, and process /me commands. Colors are <cyan>...</cyan>, specify background with <fg:bg>...</fgcolor:bgcolor>. Valid colors are white, black, navy, green, red, maroon, purple, orange, yellow, lime, teal, aqua, cyan, blue, pink, grey, and silver
   311    * Parse bold (<b>...</b>) tags and color tags in a text into IRC speak, and process /me commands. Colors are <cyan>...</cyan>, specify background with <fg:bg>...</fgcolor:bgcolor>. Valid colors are white, black, navy, green, red, maroon, purple, orange, yellow, lime, teal, aqua, cyan, blue, pink, grey, and silver
   260    * @param string Text to filter
   312    * @param string Text to filter