Advertisement
Guest User

phrac

a guest
May 11th, 2009
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?
  3. $say = $_SERVER["argv"][1];
  4. $server_host = "<irc server here>";
  5. $server_port = 6667;
  6. $server_chan = "<what channel to speak in>";
  7. $nick = '<script nickname>';
  8. $user = '<script username>';
  9. $botnick = '<bot nick>'; // what bot on the channel will do the talking
  10. $botauthpw = '<bot password>'; // if your bot requires auth for it to use the "say" command
  11. set_time_limit(0);
  12.  
  13. $server = array();
  14. $server['SOCKET'] = @fsockopen($server_host, $server_port, $errno, $errstr, 2);
  15.  
  16. if($server['SOCKET']) {
  17.   SendCommand("PASS NOPASS\n\r");
  18.   SendCommand("NICK $nick\n\r");
  19.   SendCommand("USER $user USING PHP IRC\n\r");
  20.  
  21.   while(!feof($server['SOCKET'])) {
  22.     // main loop
  23.     $server['READ_BUFFER'] = fgets($server['SOCKET'], 1024); //get a line of data from the server
  24.      echo "[RECEIVE] ".$server['READ_BUFFER'].""; //display the received data from the server
  25.  
  26.  
  27.     if(strpos($server['READ_BUFFER'], "registered")) { // this waits for Nickserv to say this nick is/is not registered before doing any commands
  28.       // wait for response from Nickserv
  29.       SendCommand("PRIVMSG $botnick :auth $botauthpw\n\r"); // ask logbot for list of nicks in the channel
  30.       SendCommand("PRIVMSG $botnick :say $server_chan $say\n\r");
  31.       SendCommand("QUIT\n\r");
  32.     }
  33.  
  34.     if(substr($server['READ_BUFFER'], 0, 6) == "PING :") {
  35.       // If the server has sent the ping command, respond
  36.       SendCommand("PONG :".substr($server['READ_BUFFER'], 6)."\n\r"); //Reply with pong
  37.     }
  38.  
  39.     // flush the output buffer
  40.     flush();
  41.   }
  42. }
  43.  
  44. // send commands to the server
  45. function SendCommand ($cmd) {
  46.   global $server;
  47.   @fwrite($server['SOCKET'], $cmd, strlen($cmd)); //sends the command to the server
  48.   echo "[SEND] $cmd";
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement