Advertisement
Evolutio

IRCBOT

Apr 2nd, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.62 KB | None | 0 0
  1. <?php
  2.  
  3. set_time_limit(0);
  4. ini_set('display_errors', 'on');
  5.  
  6. $config = array(
  7.      'server' => 'url ohne http://www.*********.de oder IP',
  8.      'port'   => 'Port',
  9.        'channel' => 'Channelname mit #Davor zb: #Nehirm',
  10.         'name'   => 'Channel Bot - #Nehirm',      
  11.         'nick'   => 'ChanServ',
  12.         'pass'   => 'Meist leerlassen',
  13.         'ident' => 'Identit�t z.B Nehirm das s�he so aus: [email protected]',
  14. );
  15.  
  16.  
  17. class IRCBot {
  18. var $socket;
  19. var $ex = array();
  20. var $info = "Dies is eine Info, die mit dem befehl !info aufgerufen werden kann";
  21. var $witze = "Was fragt Abraham, Betraham? Kann ich ma n Zebra ham.";
  22. var $neil = "Neil du sollst Evolutio mal anschreiben ^^";   function __construct($config)         {
  23.                 $this->socket = fsockopen($config['server'], $config['port']);
  24.  
  25.                 $this->login($config);
  26.  
  27.         }
  28.  
  29.          function login($config)        {                $this->sd('PASS', $config['pass']);
  30.                 $this->sd('USER', $config['ident'].' test test :'.$config['name']);                $this->sd('NICK', $config['nick']);        }
  31.          public function main($config)
  32.         {
  33.                 $data = fgets($this->socket, 256);
  34.                  echo nl2br($data);
  35.                 flush();
  36.  
  37.  
  38.                 $this->ex = explode(' ', $data);
  39.                 if($this->ex[0] == 'PING')
  40.                 {                        $this->sd('PONG', $this->ex[1]); //spielt pingpong mit dem server um die verbindung aufrechtzuerhalten ;)
  41.                         }
  42.                  $unick = explode('!', $this->ex[0]);
  43.                 $nicku = explode(':', $unick[0]);
  44.                 $message = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]." :"));
  45.                 $messageminuseins = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]));
  46.                 $message = trim($message);                $dbgmessage = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]." :".$this->ex[3]));
  47.                 $setmessage = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]." :".$this->ex[3]." ".$this->ex[4]));                $uhost = explode('@', $this->ex[0]);                $mps = explode(' ',$message);
  48.  
  49.  switch($this->ex[1]) {
  50.  case 'JOIN':
  51.  $this->msg($this->ex[2],'Da ist wohl wer gejoint! - Hallo '.$nicku[1]);
  52.  
  53.  break;
  54.  }
  55.  
  56.  
  57.  
  58.                if($this->ex[1] == "JOIN" AND $uhost[1] =="Evolutio.user.OnlineGamesNet") $this->sd('MODE '.$this->ex[1].' +o '.$nicku[1]); switch($mps[0]) {
  59.                    case '!join':
  60.                    $this->sd("JOIN ".$mps[1]);
  61.                    break;
  62.  
  63.                     case '!die':
  64.                    die();
  65.                     break;
  66.  
  67.                    case "!part":
  68.                    $this->sd("PART ".$mps[1]);
  69.                    break;
  70.  
  71.                      case "!kick":
  72.                    $this->sd("KICK ".$this->ex[2]." ".$mps[1]);
  73.                    break;
  74.  
  75.                    case '!info':
  76.                    $this->msg($this->ex[2],$this->info);
  77.                     break;
  78.  
  79.                    case '!witze':
  80.                    $this->msg($this->ex[2],$this->witze);
  81.                     break;
  82.  
  83.                       case '!oup':
  84.                     if($uhost[1] =="Evolutio.user.OnlineGamesNet" OR $uhost[1]=="Neil.user.OnlineGamesNet") {
  85.                     if(isset($mps[1])) $nick = $mps[1]; else $nick = $nicku[1]; $this->sd('MODE '.$this->ex[2].' +o '.$nick);
  86.                     }
  87.                      break;
  88.  
  89.                    case '!odown':
  90.                    $this->sd('MODE '.$this->ex[2].' -o '.$nicku[1]);
  91.                    break;
  92.  
  93.                       case '!vup':
  94.                     if($uhost[1] =="Evolutio.user.OnlineGamesNet" OR $uhost[1]=="Neil.user.OnlineGamesNet") {
  95.                     if(isset($mps[1])) $nick = $mps[1]; else $nick = $nicku[1]; $this->sd('MODE '.$this->ex[2].' +v '.$nick);
  96.                     }
  97.                      break;
  98.  
  99.                    case '!vdown':
  100.                    $this->sd('MODE '.$this->ex[2].' -v '.$nicku[1]);
  101.                    break;
  102.                                 case '!wakeup':
  103.                    if(isset($mps[1]))
  104.                    $this->msg($this->ex[2],$mps[1].' , Du sollst mal Evolutio anschreiben!');
  105.                    break;
  106.  
  107.                    case '!debug':
  108.                    eval($dbgmessage);
  109.                    break;
  110.  
  111.                }
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.             }
  120.  
  121.          function sd($cmd, $msg=NULL) //displays stuff to the broswer and sends data to the server.
  122.         {
  123.                 if($msg == NULL)
  124.                 {
  125.                         fputs($this->socket, $cmd."\r\n");                        echo '<strong>'.$cmd.'</strong><br />';                } else {
  126.                         fputs($this->socket, $cmd.' '.$msg."\r\n");
  127.                         echo '<strong>'.$cmd.' '.$msg.'</strong><br />';
  128.  
  129.                 }
  130.         }
  131.         function msg($target,$msg) {
  132.                 fputs($this->socket, 'PRIVMSG '.$target.' :'.$msg."\r\n");
  133.                echo '<strong>PRIVMSG '.$target.' :'.$msg.'</strong><br />';
  134.  
  135.         }
  136.         function notice($target,$msg) {
  137.                 fputs($this->socket, 'NOTICE '.$target.' :'.$msg."\r\n");
  138.                echo '<strong>NOTICE '.$target.' :'.$msg.'</strong><br />';
  139.          }
  140.  
  141.                    function in_str($search,$subject) {
  142.             if(str_replace($search,'',$subject) == $subject) return false;
  143.             else return true;        }
  144.  
  145.          }
  146.         $bot = new IRCbot($config);        while(1) {
  147.       $bot->main($config);  }
  148.  
  149.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement