Public feed #727583

Something

public php v1 · immutable
Raw Edit
·published 2007-10-06 04:33 UTC
rendered paste body
<?phpclass bot { var $socket; var $nick = "MehBot"; 	//Connect to server	public function cnnct() 	{	$this->socket = fsockopen("irc.hackthissite.org", 6667);	fputs($this->socket,"USER $this->nick ziandia.com XX :$this->nick \n");        fputs($this->socket,"NICK $this->nick\n");  	fputs($this->socket,"JOIN #meh\n");	}	//Respond to PINGS	public function ping($response)	{	 fputs($this->socket, "PONG ".$response."\n");	}	}class cmds extends bot {	public function sayit($channel)	{	  fputs($this->socket, "PRIVMSG ".$channel." :Test meh!\n");        }	}//Create bot object and connect$bot = new bot;$bot->cnnct();//Create new object to deal with commands$cmds = new cmds;//Force an endless loopwhile(1){	while($data = fgets($bot->socket, 128))	{		//Seperate data	        $ex = explode(' ', $data);			echo $data;				//Respond to PINGS		if($ex[0] == "PING")		$bot->ping($ex[1]);					if($ex[3] == ":!sayit")		$cmds->sayit($ex[2]);			}}?>