All pastes #812681 Raw Edit

Someone

public text v1 · immutable
·published 2007-12-11 23:13 UTC
rendered paste body
<?php

$host='irc.quakenet.org';
$port=6667;
$mynickname='R7';





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

// Opening the socket to the Quakenet network
$socket = fsockopen($host,$port,$errno,$errstr,15);
if (!$socket) die("Error: $errstr ($errno)\n");

// Send auth info
fputs($socket,"USER R7 fracs.net Ruthless :Ruth\n");
fputs($socket,"NICK R7\n");



$auth = 1;


// Force an endless while
    while (true) {
		$data=fgets($socket);
        echo $data;
		
        // Separate all data
        $ex = explode(' ', $data);
		
		
	
  
        // Send PONG back to the server
        if($ex[0] == "PING"){
            fputs($socket, "PONG ".$ex[1]."\n");
			if ($auth == 1) { 
				sleep(10);
				fputs($socket, "PRIVMSG Q@CServe.quakenet.org :AUTH Ruthless Xbox360\n");
				sleep(1);
				fputs($socket, "MODE ".$mynickname." +x\n");
				sleep(3);
				$channelfile = "channels.txt";
				$channels = file($channelfile);	
				for($c = 0;$c < count($channels);$c++){ fputs($socket, "JOIN ".$channels[$c]."\n"); }
				$auth = 2;
			}	
        }
		if ($ex[1] == "PRIVMSG") {
			$useraddress=substr($ex[0],1);
			$nickname=substr($useraddress,0,strpos($useraddress,'!'));
			$ident=substr($useraddress,strpos($useraddress,'!')+1,-strpos($useraddress,'@')-1);
			$hostname=substr($useraddress,strpos($useraddress,'@')+1);
			$channel=$ex[2];
			//PM
			if ($channel=='R7') {
				$lastnick = $nickname;
				$to_receive .= "";
				for($i = 3;$i < count($ex);$i++){ $to_receive = $to_receive." ".trim($ex[$i]); }
				$to_receive = substr($to_receive,strpos($to_receive,':',1)+1);
				fputs($socket, "PRIVMSG #ruth.priv :".chr(2).chr(3)."4<[PM]> ".chr(3).chr(2).chr(3)."12<".$nickname."> ".chr(3).$to_receive."\n");
				$to_receive = "";
			}
		}
		
			
        // Say something in the channel
        
		
		$command = trim($ex[3]);
		
			//Main channel commands
			
				if ($channel == "#the.ruthless") {				
					if ($command == ":!sctfl" && !isset($floodtime)) {
						fputs($socket, "PRIVMSG #ruth.priv :".chr(3)."7,1 «".chr(3)."0".chr(2).$nickname.chr(2).chr(3)."7» ".chr(3)."0 would like an SCTFL match\n");
						fputs($socket, "PRIVMSG #the.ruthless :".chr(3)."7,1 «".chr(3)."0".chr(2)."The members have been informed.".chr(2).chr(3)."7» ".chr(3)."\n");
						$floodtime = time() + 5;
					}
					while (isset($floodtime)) {
					if (time() > $floodtime) {
						unset($floodtime);
					}
				}
				}
				
			
			//Priv Chan commands
			if ($channel == "#ruth.priv") {
				if ($command == ":!muffin") {
					fputs($socket, "PRIVMSG #ruth.priv :".chr(3)."7,1 «".chr(3)."0".chr(2)."Muffin Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://u13.net:20000/muffin\n");
				}
				if ($command == ":!server") {
					fputs($socket, "PRIVMSG #ruth.priv :".chr(3)."7,1 «".chr(3)."0".chr(2)."Ruthless Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://208.70.146.121:70000/ruth\n");
				}
				if ($command == ":!OC") {
					fputs($socket, "PRIVMSG #ruth.priv :".chr(3)."7,1 «".chr(3)."0".chr(2)."OC Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://208.70.146.121:41337/newera\n");
				}
				if ($command == ":!deth") {
					fputs($socket, "PRIVMSG #ruth.priv :".chr(3)."7,1 «".chr(3)."0".chr(2)."DETH Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://208.70.146.121:25555/ugapa\n");
				}
				if ($command == ":!LP") {
					fputs($socket, "PRIVMSG #ruth.priv :".chr(3)."7,1 «".chr(3)."0".chr(2)."LP Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://u13.net:30089/LP\n");
				}
				if ($command == ":!roll") {
					fputs($socket, "PRIVMSG #ruth.priv : ".$nickname." rolled ".chr(2).rand(0,15).chr(2)."\n");
				}
				if ($command == ":!serv") {
					fputs($socket, "PRIVMSG ".$ex[4].":".chr(3)."7,1 «".chr(3)."0".chr(2)."Ruthless Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://208.70.146.121:70000/ruth\n");
					fputs($socket, "PRIVMSG #ruth.priv :Server info sent to ".$ex[4]."\n");
				}
				if ($command == ":!servlast") {
					fputs($socket, "PRIVMSG ".$lastnick.":".chr(3)."7,1 «".chr(3)."0".chr(2)."Ruthless Server".chr(2).chr(3)."7» ".chr(3)."0 soldat://208.70.146.121:70000/ruth\n");
					fputs($socket, "PRIVMSG #ruth.priv :Server info sent to ".$lastnick."\n");
				}
		        if ($command == ":!m" && count($ex) > 4) {
				//message
					$to_send .= "";
					for($i = 5;$i < count($ex);$i++){ $to_send = $to_send." ".trim($ex[$i]); }
					fputs($socket, "PRIVMSG ".$ex[4]." :".chr(3)."12<".$nickname.">".chr(3).$to_send."\n");
					$to_send = "";
		        }
				if ($command == ":!r" && count($ex) > 4) {
				//reply
					$to_reply .= "";
					for($i = 4;$i < count($ex);$i++){ $to_reply = $to_reply." ".trim($ex[$i]); }
					fputs($socket, "PRIVMSG ".$lastnick." :".chr(3)."12<".$nickname.">".chr(3).$to_reply."\n");
					$to_reply = "";
		        }
				//Changes nick
				if ($command == ":!nick") {
					fputs($socket, "NICK ".$ex[4]."\n");
					$mynickname = $ex[4];
				}
				//Joins channel
		        if ($command == ":!j") {
		            fputs($socket, "JOIN ".$ex[4]." ".$ex[5]."\n");
		        }
				//Leaves channel
				if ($command == ":!p") {
		            fputs($socket, "PART ".$ex[4]." ".$ex[5]."\n");
		        }
				//Auths/+x
				if ($command == ":!auth") {
		            fputs($socket, "PRIVMSG Q@CServe.quakenet.org :AUTH Ruthless Xbox360\n");
					fputs($socket, "MODE ".$mynickname." +x\n");
		        }
				// To quit the bot
				if($command == ":!quit" && $hostname == "Lordrohith-.users.quakenet.org"){
					fputs($socket,"QUIT :lolquitmsg\n");
				}
			}
		
    }
fclose($socket);
?>