Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

irc bot php
Tuesday, March 18th, 2008 at 11:48:09am MDT 

  1. <?php
  2. // Set the script to run even after closing browser
  3. // Prevent PHP from stopping the script after 30 sec (default timeout)
  4.  
  5. // Opening the socket to the ircnet network
  6. $socket = fsockopen("irc.cc.tut.fi", 6667) or die();
  7.  
  8. // Send auth info
  9. fputs($socket,"USER Naama x.net CM :CM bot\n");
  10. fputs($socket,"NICK diipadaapa\n");
  11.  
  12. // Join channel
  13. fputs($socket,"JOIN #1112\n");
  14.  
  15. // Force an endless while
  16.  
  17. while(1) {
  18.  
  19.     // Continue the rest of the script here
  20.                 while($data = fgets($socket, 256)) {
  21.  
  22.         echo nl2br($data);
  23.         flush();
  24.      
  25.            $ex = explode(' ', $data);
  26.                                 $command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
  27.  
  28.                                 // Send PONG back to the server
  29.                                 if($ex[0] == "PING"){
  30.         fputs($socket, "PONG ".$ex[1]."\n");
  31.         }
  32.                                 if($command == ":!stop"){
  33.                                 fputs($socket,"PRIVMSG $ex[2] duidui!\n");
  34.                                 die();
  35.                                 }
  36.                                 $cmd = "PRIVMSG ".$ex[2];
  37.                                 $msg = " :hei moi";
  38.                                 if($command == ":!hep"){
  39.                                 fputs($socket, $cmd.' '.$msg."\n");
  40.                                 }
  41.                                 echo '<pre>';
  42.                                 print_r($ex);
  43.                                 echo '</pre>';
  44.                 }
  45.  
  46.                 usleep(10000);
  47. }
  48. ?>

Paste Details

Tags: php irc bot

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation