nick = $nick; $this -> username = $username; $this -> realname = $realname; } /* * General Stuff */ public function auth(){ return "USER ".$this -> username." as as :".$this -> realname; } public function nick(){ return "NICK ".$this -> nick; } public function setNick($nick){ if($this -> nick != $nick){ $this -> nick = $nick; return $this -> nick(); } } public function join($channel){ return "JOIN ".$channel; } public function part($channel, $msg){ return "PART ".$channel." :".$msg; } public function away($msg){ return "AWAY :".$msg; } public function kick($channel, $nick, $msg=""){ return "KICK ".$channel." ".$nick." :".$msg; } public function quit($msg){ return "QUIT :".$msg; } public function privmsg($target, $msg){ return "PRIVMSG ".$target." :".$msg; } public function notice($target, $msg){ return "NOTICE ".$target." :".$msg; } /* * General Mode Stuff */ public function mode($channel, $detail){ return "MODE ".$channel." ".$detail; } public function op($channel, $nick){ return $this -> mode($channel, "+o ".$nick); } public function deop($channel, $nick){ return $this -> mode($channel, "-o ".$nick); } public function voice($channel, $nick){ return $this -> mode($channel, "+v ".$nick); } public function devoice($channel, $nick){ return $this -> mode($channel, "-v ".$nick); } public function mute($channel){ return $this -> mode($channel, "+m"); } public function unmute($channel){ return $this -> mode($channel, "-m"); } /* * parsing incoming IRC-Lines */ public function parse($msg){ if(trim($msg) == "") return false; $expl = explode(":", $msg, 3); $message = (isset($expl[2])) ? $expl[2] : ""; if(isset($expl[1])) $data = explode(" ", $expl[1]); //Here we need to decide whether it's a SMSG or a usual MSG if(isset($data[0]) && preg_match("/!/", $data[0])){ $nick = explode("!", $data[0]); $banhost = (substr($nick[1],1,1) == "=") ? substr($nick[1], 2) : $nick[1]; $iphost = explode("@", $banhost); $iphost = $iphost[1]; $servermsg = false; } else{ if(isset($data[0])) $iphost = $banhost = $data[0]; $servermsg = true; } $msgarr = explode(" ", $message); $i = 0; foreach($msgarr as $key){ $marr[$i] = $key; $i++; } unset($i); unset($msgarr); $result['servermsg'] = $servermsg; $result['nick'] = (isset($nick[0])) ? $nick[0] : ""; $result['banhost'] = (isset($banhost)) ? $banhost : ""; $result['iphost'] = (isset($iphost)) ? $iphost : ""; $result['action'] = (isset($data[1])) ? $data[1] : ""; $result['message'] = $message; $result['msgarr'] = $marr; $result['line'] = $msg; $result['target'] = (isset($data[2])) ? $data[2] : ""; $result['origin'] = ($result['target'] == $this -> nick) ? $result['nick'] : $result['target']; $result['param'] = (isset($data[3])) ? $data[3] : ""; return $result; } public function getArgs($start, $recv){ $i = 0; while($i < $start){ if(isset($recv["msgarr"][$i])) unset($recv["msgarr"][$i]); $i++; } return implode(" ", $recv["msgarr"]); } /* * check for certain events */ public function checkQuery($recv){ return ($recv["action"] == "PRIVMSG" && strtolower($recv["target"]) == strtolower($this -> nick)) ? true : false; } public function checkChannel($recv){ return ($recv["action"] == "PRIVMSG" && strtolower($recv["target"]) != strtolower($this -> nick)) ? true : false; } public function checkCommand($prefix, $recv){ return (isset($recv["message"][0]) && $recv["message"][0] == $prefix && $recv["action"] == "PRIVMSG" && strtolower($recv["target"]) != strtolower($this -> nick)) ? true : false; } public function getCommand($prefix, $recv){ $expl = explode(" ", $recv["message"], 2); return str_replace($prefix, "", $expl[0]); } /* * reacting to PING Lines... */ public function checkPing($msg){ return (preg_match("/^PING :/", $msg)) ? str_replace("PING", "PONG", $msg) : ""; } } ?>