sock) ? true : false; } public function connectionConnect($server, $port=6667){ $this->sock = fsockopen($server, $port); if(!$this->sock) return false; $this->server_host = $server; $this->server_port = $port; return true; } public function connectionRegister($nick, $username, $hostname, $servername, $realname){ if(!$this->isConnected()) return false; if(!$this->sendCommand("USER $username $hostname $servername $realname")) return false; $this->setNick($nick); return true; } private function sendCommand($data, $suffix = "\n"){ if(!$this->isConnected()) return false; echo " SENDING DATA $data\n"; $bytes_written = fputs($this->sock, $data.$suffix); if(!$bytes_written) return false; return true; } private function setNick($newNick){ if(!$this->isConnected()) return false; $this->sendCommand("NICK $newNick"); } public function joinChannel($channel){ if(!$this->isConnected()) return false; if(substr($channel,0 ,1) != "#") return false; if(!$this->sendCommand("JOIN $channel")) return false; return true; } public function startListen(){ $this->run_loop = true; $this->mainLoop(); } public function stopListen(){ $this->run_loop = false; } public function mainLoop($times=null){ global $inf0; stream_set_timeout($this->sock, 1); while($this->run_loop){ if($times != null){ $times--; if($times == 0){ $this->run_loop = false; continue; } } if(!$data = fgets($this->sock, 128)){ continue; } echo "$data"; // Separate all data $ex = explode(' ', $data); for($i=0; $isendCommand("PONG ".$ex[1]); } if(isset($last_cmd) && TIME() - $last_cmd < 2) continue; $last_cmd = TIME(); // Say something in the channel $command = str_replace(array(chr(10), chr(13)), '', $ex[3]); switch($command){ case ":!l": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :".$name."is LRON!"); break; case ":!help": foreach($inf0 as $line) $this->sendCommand("PRIVMSG {$ex[2]} :$line"); break; case ":!contact": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :To contact Manchester Anonymous, e-mail Anonymous@irleet.com or call 07005993680"); break; case ":!when": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :The next protest is on 15th of March"); break; case ":!where": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :The manchester Scientology branch is at 258-260 Deansgate, Manchester, M3 4BG,"); break; case ":!rules": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :The Protest rules can be found at http://downwiththe.org.uk/w/index.php/Rules"); break; case ":!what": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :Anonymous is a group of people, unknown to eachother and the rest of the world, fighting against the crimes against humanity that the so called Church of Scientology has commited, See www.whyaretheydead.net"); break; case ":!wbm": $name = ""; for($i=4; $isendCommand("PRIVMSG {$ex[2]} :Wise Beard Man may be our strongest allie in this fight, see www.xenutv.com for more information."); break; case ":!killtheb0t123": $this->stopListen(); echo "STOPPING BOT"; break; default: $ex[3] = substr($ex[3], 1); $msg = ""; for($i=3; $isendCommand("PRIVMSG {$ex[2]} :$reply"); } } usleep(1); } echo "\n\nDONE $times\n\n"; } } $inf0[0] = <<connectionConnect("irc.partyvan.org"); echo "Registering...\n"; $irc->connectionRegister("Info", "Manchesterfag", "xenu.net", "irc.partyvan.org", "lol"); $irc->mainLoop(7); echo "Joining channel...\n"; $irc->joinChannel("#Bottest"); $irc->mainLoop(5); echo "And now listening\n"; $irc->startListen(); ?>