Advertisement
makimaki

PhP Phreik Bot

Sep 29th, 2010
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <h1>PhP Bot</h1>
  2. <?php
  3. // Prevent PHP from stopping the script after 30 sec
  4. set_time_limit(0);
  5.  
  6. // Edit these settings
  7. $chan = "#afterhours";
  8. $server = "irc.phreik.net";
  9. $port = 6667;
  10. $nick = "PHP_Bot";
  11. $account = "0000070050 340c6b464ed5e1ce555a236f102795a6 PY";
  12.  
  13. // STOP EDITTING NOW.
  14. $socket = fsockopen("$server", $port);
  15. fputs($socket,"USER $nick $nick $nick $nick :$nick\n");
  16. fputs($socket,"NICK $nick\n");
  17. fputs($socket,"Account $account\n");
  18. fputs($socket,"JOIN ".$chan."\n");
  19.  
  20. while(1) {
  21.     while($data = fgets($socket)) {
  22.             echo nl2br($data);
  23.             flush();
  24.  
  25.             $ex = explode(' ', $data);
  26.         $rawcmd = explode(':', $ex[3]);
  27.         $oneword = explode('<br>', $rawcmd);
  28.             $channel = $ex[2];
  29.         $nicka = explode('@', $ex[0]);
  30.         $nickb = explode('!', $nicka[0]);
  31.         $nickc = explode(':', $nickb[0]);
  32.  
  33.         $host = $nicka[1];
  34.         $nick = $nickc[1];
  35.        
  36.             if($ex[0] == "PING"){
  37.                 fputs($socket, "PONG ".$ex[1]."\n");
  38.             }
  39.  
  40.         $args = NULL; for ($i = 4; $i < count($ex); $i++) { $args .= $ex[$i] . ' '; }
  41.          echo $args ;
  42.             if ($rawcmd[1] == "!sayit") {
  43.                 fputs($socket, "PRIVMSG ".$channel." :".$args." \n");
  44.             }
  45.         elseif ($rawcmd[1] == "!md5") {
  46.             fputs($socket, "PRIVMSG ".$channel." :MD5 ".md5('$args')."\n");
  47.         }
  48.     }
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement