All pastes #466148 Raw Edit

Untitled

public text v1 · immutable
#466148 ·published 2007-04-30 20:59 UTC
rendered paste body
<?php
set_time_limit(0);
$config = array();
$config["host"] = 'underworld.no.eu.netgamers.org';
$config["port"] = 7000;
$config["nick"] = 'botsworth';
$config['ident'] = 'z0mg';
$config['realname'] = "fancy a hump?";
$config["chan"] = '#insanespot';
$config["buffer"]= 256;
$registered = false;

// this is just for humour value
$privmsgs = array();
$actions = array(	"comes in your hair", 
			"exposes itself to your mother", 
			"points at you and laughs", 
			"jzzes on your monitor", 
			"owns you with gay porn");
$nickarray = array();
$galleryflag = array();

// numbers for useful server messages
$whoisStart = "311";
$whoisPNick = "330";
$whoisEnd = "318";

// start connection
$conn = fsockopen($config["host"], $config["port"], $errno, $errstr);

// standard send command, with writing to screen
function cmdSend ($handle, $string) 
{
    $string.="\n";
    fwrite($handle, $string);
    echo date('d/m/Y H:m:s')." <- ".$string;
}

// privmsg
function msg ($who, $message)
{
	global $conn;
	cmdSend($conn, "PRIVMSG ".$who." :".$message);
	sleep(1);
}

// notice
function notice ($who, $message)
{
	global $conn;
	cmdSend($conn, "NOTICE ".$who." :".$message);
	sleep(1);
}

// action
function action ($who, $message)
{
	global $conn;
	cmdSend($conn, "PRIVMSG ".$who." :\001ACTION ".$message."\001");
	sleep(1);
}

// join a channel
function joinchannel ($channel)
{
	global $conn;
	cmdSend($conn, "JOIN ".$channel);
}

// change nick
function nick ($nick)
{
	global $conn;
	cmdSend($conn, "NICK :".$nick);
}

// if there's no connection
if (!$conn) 
{
   die("Error ($errno): $errstr");
}

else 
{
    while (!feof($conn)) 
	{
		$line = trim(fgets($conn, $config["buffer"]));
		echo date('d/m/Y H:m:s')." -> ".$line."\n";
        $token = explode(" ", $line);
		/* print_r($token);
		echo "substr: ".substr($token[0],1,(strpos($token[0],"!")-1))."\n";
		echo "strlen(token[3]) == ".strlen($token[3])." (".$token[3].")";
		echo "strlen(trim(token[3])) == ".strlen(trim($token[3]))." (".$token[3].")"; */

		// if we haven't already told the server who we are
		if ($registered == false)	
		{
			cmdSend($conn,"USER ".strtolower($config["ident"])." 0 0 :".$config['realname']);
			cmdSend($conn,"NICK ".$config["nick"]);
	        $registered = true;
		}

		// if the server pings
		if ($token[0]=="PING")
		{
			// we pong
			cmdSend($conn, "PONG ".$token[1]);
		}

		// deal with Netgamers' shady lack of pinging
		if (!(strlen($token[0])>0))
		{
			msg("#", "pong.");
		}

		// if the server has finished its startup bollocks
		if ($token[0]==":".$config["host"] && $token[1]=="376")
		{
			cmdSend ($conn, "PRIVMSG P@Cservice.netgamers.org :login botsworth bottage1356");
			sleep(1);
			cmdSend ($conn, "MODE ".$config['nick']." +x");
			sleep(1);
			joinchannel($config['chan']);
		}

		// whois stuff
		if ($token[0]==":".$config["host"] && strlen($token[1])==3)
		{
			// print_r($token);
			$eventNum = $token[1];
			if ($eventNum == $whoisStart)
			{
				$nick = $token[3];
		        $pnick = "";
		        $ident = $token[4]; 
		        $host = $token[5];
			}
			if ($eventNum == $whoisPNick)
			{
				$pnick = $token[4];
			}
			if ($eventNum == $whoisEnd)
			{
				if (!(strlen($pnick)>0))
				{
					msg($config['chan'], $nick." (".$ident."@".$host.") is not logged into P");
				}
				else
				{
					msg($config['chan'], $nick." (".$ident."@".$host.") is logged into P as ".$pnick);
					$nickarray[$nick] = $pnick;
				}

				if ($galleryflag[$nick]="1")
				{
					if (strlen($nickarray[$nick])>0)
					{
						msg($config['chan'],"http://ng-gallery.net/view.php?nick=".$nickarray[$nick]);
					}
					else
					{
						msg($config['chan'],$nick." doesn't have an NG-Gallery page.");
					}	
				}				
				unset($nick);
				unset($pnick);
				unset($ident);
				unset($host);
			}
		}

		// if i want to whois someone
		if (strtolower(trim($token[3])) == ":!whois" && substr(trim($token[0]),1,strpos(trim($token[0]),"!")-1)=="webvictim")
		{
			if (strlen($token[4])>0)
			{
				$whois = $token[4];
				cmdSend ($conn, "WHOIS ".$whois);
			}
		}			

		// !gallery
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['chan'] && strtolower($token[3]) == ":!gallery")
		{
			if (strlen($token[4])>0)
			{
				if (strlen($nickarray[$token[4]])>0)
				{
					msg($config['chan'],"http://ng-gallery.net/view.php?nick=".$nickarray[$token[4]]);
				}
				else
				{
					$galleryflag[$token[4]]="1";
					cmdSend ($conn, "WHOIS ".$token[4]);
					// msg($config['chan'],"Too fucking complicated for tonight, tbh (no p-auth saved)");
				}
			}
		}

		// if someone says !hump whatever
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['chan'] && strtolower($token[3]) == ":!hump")
		{
			if (strlen($token[4])>0)
			{
				action($config['chan'], "humps ".$token[4]);
			}
		}

		// if someone says !tickle whatever
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['chan'] && strtolower($token[3]) == ":!tickle")
		{
			if (strlen($token[4])>0)
			{
				action($config['chan'], "tickles ".$token[4]);
			}
		}

		// if someone says !slap whatever
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['chan'] && strtolower($token[3]) == ":!slap")
		{
			if (strlen($token[4])>0)
			{
				action($config['chan'], "slaps ".$token[4]);
			}
		}
		
		// if someone says !fap whatever
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['chan'] && strtolower($token[3]) == ":!fap")
		{
			if (strlen($token[4])>0)
			{
				action($config['chan'], "faps ". $token[4]);
			}
		}

	
		// if someone /msgs the bot
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['nick'])
		{
			// $nick is the person's nick
			$nick = substr($token[0],1,(strpos($token[0],"!")-1));
			// increment the number of times they have messaged the bot for spam protection
			$privmsgs[$nick]++;
			// if it's me
			if ($nick=="webvictim")
			{
				// !hump
				if (strtolower($token[3]) == ":!hump")
				{
					action($config['chan'], "humps ".$token[4]);
				}
				// !tickle
				else if (strtolower($token[3]) == ":!tickle")
				{
					action($config['chan'], "tickles ".$token[4]);
				}
				// !slap
				else if (strtolower($token[3]) == ":!slap")
				{
					action($config['chan'], "slaps ".$token[4]);
				}
				// !fap
				else if (strtolower($token[3]) == ":!fap")
				{
					action($config['chan'], "faps ".$token[4]);
				}
			}
			// otherwise start being sarky
			else if ($privmsgs[$nick]>4 && $privmsgs[$nick]<=8)
			{
				msg($nick, "well, i'm spent.");
			}
			else if ($privmsgs[$nick]>8 && $privmsgs[$nick]<=12)
			{
				msg($nick, "don't you think it's wearing a little thin now?");
			}
			else if ($privmsgs[$nick]>12)
			{
			    continue;
			}
			else
			{
				action($nick, $actions[rand(0,5)]);
				msg($nick, "harrrr!");
			}
		}
		
		// my shocker stuff
		if ($token[1] == "PRIVMSG" && strtolower($token[2])==$config['nick'] && strtolower($token[3]) == ":!shocker")
		{
			$nick = substr($token[0],1,(strpos($token[0],"!")-1));
			if ($nick=="webvictim" || $nick=="Ashley" || $nick=="EreheMan")
			{
				$string = $token[4]." in ";
			    for ($i=5;$i<count($token);$i++)
			    {
					$string.=$token[$i]." ";
			    }
			    $string.="shocker.";
			    msg($config['chan'], $string);
			}
		}
	}
}
?>