Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 1.22 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. private function mainloop()
  2.         {
  3.                 $timers = new timers;
  4.                
  5.                 while(true)
  6.                 {
  7.                         $data = fgets($this->socket, 128);
  8.                        
  9.                         //Filter color, bold, underline and italic and double spaces
  10.                         $data   = preg_replace('/'.chr(3).'(\d{1,2})\,?(\d{1,2})?|'.chr(2).'|'.chr(31).'|'.chr(29).'|'.chr(15).'|\s\s/','',$data);
  11.                        
  12.                         echo $data."\n";
  13.                         flush();
  14.                        
  15.                         $d              = explode(' ',$data);
  16.                         for($i = 0;isset($d[$i]);$i++)
  17.                         {
  18.                                 $d[$i]  = trim(addslashes($d[$i]));
  19.                         }
  20.                                
  21.                         if ($d[1] == '376') { $motd = 'displayed'; } //Join channels after MOTD is displayed
  22.                        
  23.                         if ($motd == 'displayed' && count($this->myChans) == 0)
  24.                         {
  25.                                 $chans = $this->config['connect']['channels'];
  26.                                 $chans = preg_split('/\,/',trim($chans));
  27.                                
  28.                                 foreach($chans as $channel)
  29.                                 {
  30.                                         $this->write('JOIN '.$channel);
  31.                                         array_push($this->myChans,$channel);
  32.                                 }
  33.                         }
  34.                        
  35.                         if($d[0] == 'PING')
  36.                         {
  37.                                 $this->write('PONG '.$d[1]);
  38.                         }
  39.                        
  40.                         if ($d[3] == ":!quit")
  41.                         {
  42.                                 $this->write("QUIT :Quit - Command by ".$Nick);
  43.                                 socket_close($this->socket);
  44.                                 die('Bot was shut down.');
  45.                         }
  46.  
  47.                         $timers->checkTimers();
  48.                        
  49.                         include('inc/pokerscript.php');
  50.                        
  51.                         //require('inc/script.php');
  52.                
  53.                 }
  54.         }