function Send($sData) { socket_write($this->Socket,$sData."\r\n"); echo $sData."
"; } function Say($sChannel, $sInput) { $this->Send("PRIVMSG ".$sChannel." :".$sInput); } function Notice($sUsername, $sInput) { $this->Send("NOTICE ".$sUsername." :".$sInput); } function Nick($aArray) { if(is_array($aArray)) { $this->sNick = $aArray[0]; $this->sRealname = $aArray[1]; $this->sIdent = $aArray[2]; if(isset($aArray[4])) { $this->sHostname = $aArray[3]; } else { $this->sHostname = 0; } $this->Send('USER '.$this->sIdent.' '.$this->sHostname.' '.$this->sServer.' :'.$this->sRealname); $this->Send('NICK '.$this->sNick); } $this->AutoJoin(); } function LogIn($sPassword) { $this->Say("NickServ", "IDENTIFY ".$sPassword); } function Join($sChannel, $sKey=false) { $sChannel = strtoupper($sChannel); if($sKey) { $this->Send("JOIN ".$sChannel." ".$sKey); } else { $this->Send("JOIN ".$sChannel); } if(!is_array($this->aInChannel)) { $this->aInChannel = array(); } if(!in_array($sChannel,$this->aInChannel)) { $this->aInChannel[] = $sChannel; } array_unique($this->aInChannel); } function AutoJoin() { $rSQL = mysql_query("SELECT * FROM `tblautojoin`"); while($aAssoc = mysql_fetch_assoc($rSQL)) { if(!empty($aAssoc['Channel'])) { if(empty($aAssoc['Key'])) { $this->Join($aAssoc['Channel']); } else { $this->Join($aAssoc['Channel'], $sKey); } if(!empty($aAssoc['AutoMessage'])) { $this->Say($aAssoc['Channel'], $aAssoc['AutoMessage']); } } } } if(preg_match("/^!restart$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 4) { array_unique($this->aInChannel); foreach($this->aInChannel AS $iKey => $sValue) { setcookie("Channel[".$sValue."]", $sValue, time() + time()); } $this->AMSG("Restarting Bot",$Message[1]); $this->Send("QUIT"); } if(preg_match("/^!part all$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 3) { array_unique($this->aInChannel); $this->AMSG("Parting all NON-AutoJoin Channels", $Message[1]); $rSQL = mysql_query("SELECT * FROM tblautojoin") or die(mysql_error()); while($aAssoc = mysql_fetch_assoc($rSQL)) { $aAutoJoin[] = strtoupper($aAssoc['Channel']); } foreach($this->aInChannel AS $key => $sChannel) { $sChannel = strtoupper($sChannel); if(!in_array($this->Safe($sChannel),$aAutoJoin)) { $this->Part($sChannel); } } }