<?php

/*
 *
 * Anna bot v2.0 (Reloaded)
 *
 * By Maikel Gommans
 * maikel@maikelg.eu
 * http://www.maikelg.eu
 *
 * File desc: IRC class
 * File created: Zaterdag 09-12-2006
 * Last changed: Zaterdag 09-12-2006
 *
 */

 
class irc {

     private 
$port;
     private 
$host;
     private 
$bindip;
     private 
$channel;
     private 
$nick;
     private 
$sock;
     
     
     public function 
setBindip($bindip) {
    
         
$this->bindip $bindip;
         
     }
     
      public function 
connect($host,$port) {
    
          
$this->sock socket_create(AF_INETSOCK_STREAMSOL_TCP);
          
socket_bind($this->sock$this->bindip);
          
          
$this->host $host;
          
$this->port $port;
          
          
socket_connect($this->sock$host$port);
          
      }
      
      public function 
raw($i) { 
          
          
socket_write($this->sock,$i."\r\n");
          echo 
$i "\n";
      
      }
      
      public function 
user($nick) {
    
          
$this->nick $nick;
          
$this->raw('USER '.$nick.' '.$this->host.' '.$this->bindip.' : '.$nick.' Powered by maikelg irc framework v2.0');
          
$this->raw('NICK '.$nick);
          
      }
      
      public function 
chgChan($i) {
        
          
$this->raw('PART :'.$this->channel);
          
$this->raw('JOIN :'.$i);
          
$this->channel $i;
          
      }
      
      public function 
fJoin($i) {
        
          
$this->raw('JOIN :'.$i);
          
$this->channel $i;
          
      }
      
      public function 
quit($i) {
        
          
$this->raw('QUIT :'.trim($i));
          
socket_close($this->sock);
          
      }
      
       public function 
chgNick($i) {
        
          
$this->raw('NICK '.$i);
          
$this->nick $i;
          
      }
      
      public function 
read() {
    
          return 
socket_read($this->sock,1024);
          
      }
      
      public function 
say($i) {
        
         
$this->raw('PRIVMSG '.$this->channel.' :'.$i);  
          
      }
      
      public function 
pm($user,$i) {
        
         
$this->raw('PRIVMSG '.$user.' :'.$i);  
          
      }
      
      public function 
me($i) {
        
          
$this->raw('PRIVMSG '.$this->channel.' :ACTION '.$i);
          
      }
      
      public function 
pmme($user,$i) {
        
          
$this->raw('PRIVMSG '.$user.' :ACTION '.$i);
          
      }
      
 }

?>