rendered paste body<?php
class bot {
public
$server = "darklite.be.eu.swiftirc.net",
$botname = "o{|PartyServ",
$channels = "#o{|",
$socket;
function __construct() {
$conn = stream_context_create(array('socket'=>array('bindto' => "64.18.146.48:0")));
$this->socket=stream_socket_client("tcp://".$this->server.":8080",$err,$errnum,5,STREAM_CLIENT_CONNECT,$conn);
stream_set_timeout($this->socket, 600);
$this->send("NICK ".$this->botname);
$this->send("USER $this->botname 8 * :phpBot");
while ($temp = fgets($this->socket)) {
if (strpos($temp, "376")>0) {
$this->send("MODE ".$this->botname." -x");
$this->send("JOIN ".$this->channels);
$this->send("PRIVMSG nickserv id ");
sleep(1);
$this->send("MODE #o{| -oa ".$this->botname." ".$this->botname);
break;
}
}
}
function get_nick($line) {
$questionmark = strpos($line, "!") - 1;
return substr($line, 1, $questionmark);
}
function get_channel($line) {
$lines = explode(" ",$line);
return $lines[2];
}
function pong ($ping) {
fwrite($this->socket, "PONG :$ping\r\n");
}
function send ($line) {
fwrite($this->socket, $line."\r\n");
}
function gettok($line, $token = 0) {
$tok = explode(" ",$line);
return $tok[$token];
}
function text_line($line) {
return trim(substr($line,strpos($line,":",2) + 1));
}
}
ignore_user_abort(TRUE);
set_time_limit(0);
$bot = new bot();
while ($t = fgets($bot->socket)) {
if (stristr($t,"PING :")) {
$bot->pong(substr($t,6));
}
if ($bot->gettok($t,1) == "JOIN" && strpos($bot->get_nick($t),"o{|") === 0) {
fwrite($bot->socket,"PRIVMSG chanserv voice #o{| ".$bot->get_nick($t)."\r\n");
}
if ($bot->gettok($t,1) == "NICK" && strpos($bot->gettok($t,2),"o{|") === 1 && strpos($bot->get_nick($t),"o{|") === false) {
fwrite($bot->socket,"PRIVMSG chanserv voice #o{| ".substr($t,strpos($t,":",1) + 1,-1)."\r\n");
}
if ($bot->gettok($t,1) == "NICK" && strpos($bot->gettok($t,2),"o{|") === false && strpos($bot->get_nick($t),"o{|") === 0) {
fwrite($bot->socket,"PRIVMSG chanserv devoice #o{| ".substr($t,strpos($t,":",1) + 1,-1)."\r\n");
}
echo $t;
}
?>