All pastes #675692 Raw Edit

irc bot

public text v1 · immutable
#675692 ·published 2007-08-30 12:07 UTC
rendered paste body
<html>
<head>
<title>IRC Bot</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// Prevent PHP from stopping the script after 30 sec
set_time_limit(0);

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

// Send auth info
fputs($socket,"USER WhiteyBot combined-minds.net CM :`Whitey is the Owner\n");

fputs($socket,"NICK `WhiteyBot \n");
// Join channel
fputs($socket,"JOIN #weepee\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");
    }

  }

}

?>

<?php

$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);

?>

</html>