All pastes #564201 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-13 14:20 UTC
rendered paste body
<?php
include('Net/SmartIRC.php');

// Prevent PHP from stopping the script after 30 sec
set_time_limit(0);

// Opening the socket to the swiftirc network
$socket = fsockopen("magic.swiftirc.net", 6667);

// Send auth info
fputs($socket,"USER adz bot RAD :sam\n");
fputs($socket,"NICK adzbot\n");

// Join channel
fputs($socket,"JOIN #ninesix\n");

// Force an endless while
while(1) {

    // Continue the rest of the script here
    while($data = fgets($socket, 128)) {

        echo nl2br($data);
        flush();

        // Separate all data
        $ex = explode(' ', $data);

        // Send PONG back to the server
        if($ex[0] == "PING"){
            fputs($socket, "PONG ".$ex[1]."\n");
        }

        // Say something in the channel
        $command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
        if ($command == ":!info") {
            fputs($socket, "NOTICE ".$ex[2]." :adz's PHP mIRC Bot!\n");
        }

    }

}

$irc->connect('magic.swiftirc.net', 6667);


?>