Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/php
- <?
- $say = $_SERVER["argv"][1];
- $server_host = "<irc server here>";
- $server_port = 6667;
- $server_chan = "<what channel to speak in>";
- $nick = '<script nickname>';
- $user = '<script username>';
- $botnick = '<bot nick>'; // what bot on the channel will do the talking
- $botauthpw = '<bot password>'; // if your bot requires auth for it to use the "say" command
- set_time_limit(0);
- $server = array();
- $server['SOCKET'] = @fsockopen($server_host, $server_port, $errno, $errstr, 2);
- if($server['SOCKET']) {
- SendCommand("PASS NOPASS\n\r");
- SendCommand("NICK $nick\n\r");
- SendCommand("USER $user USING PHP IRC\n\r");
- while(!feof($server['SOCKET'])) {
- // main loop
- $server['READ_BUFFER'] = fgets($server['SOCKET'], 1024); //get a line of data from the server
- echo "[RECEIVE] ".$server['READ_BUFFER'].""; //display the received data from the server
- if(strpos($server['READ_BUFFER'], "registered")) { // this waits for Nickserv to say this nick is/is not registered before doing any commands
- // wait for response from Nickserv
- SendCommand("PRIVMSG $botnick :auth $botauthpw\n\r"); // ask logbot for list of nicks in the channel
- SendCommand("PRIVMSG $botnick :say $server_chan $say\n\r");
- SendCommand("QUIT\n\r");
- }
- if(substr($server['READ_BUFFER'], 0, 6) == "PING :") {
- // If the server has sent the ping command, respond
- SendCommand("PONG :".substr($server['READ_BUFFER'], 6)."\n\r"); //Reply with pong
- }
- // flush the output buffer
- flush();
- }
- }
- // send commands to the server
- function SendCommand ($cmd) {
- global $server;
- @fwrite($server['SOCKET'], $cmd, strlen($cmd)); //sends the command to the server
- echo "[SEND] $cmd";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement