PHPIrc_bot - (c) 2006 Thorben Gartmann - type "less $PATH_TO_PHPIrc_bot/GPL" for more info. irc = IRC::factory($this->server, $this->port, $this->nickname, $this->username, $this->servername, $this->realname); while (true) { $input = $this->irc->get(); $this->do_hooks($input); } } function add_hook($command, $function) { $this->hooks[] = array("command" => $command, "function" => $function); } function add_privmsg_hook($command, $function, $channel = "*") { $this->privmsg_hooks[] = array("command" => $command, "function" => $function, "channel" => $channel); } function do_hooks($input) { foreach ($this->hooks AS $hook) { if ($hook["command"] == $input["command"]) { call_user_func($hook["function"], $this->irc, $input["command"], $input["params"], $input["prefix"]); } } if ($input["command"] == "PRIVMSG") { foreach ($this->privmsg_hooks AS $hook) { $string = $hook["channel"] . " :" . $hook["command"]; $string2 = strstr($input["params"], ":"); if ($hook["channel"] != "*" && substr($input["params"], 0, strlen($string)) == $string) { call_user_func($hook["function"], $this->irc, substr($input["params"], strlen($string) + 1), $input["prefix"], $hook["channel"]); } elseif (substr($string2, 0, strlen($hook["command"]) + 1) == ":" . $hook["command"]) { $params_pos = @strpos($input["params"], $hook["command"]) + strlen($hook["command"]) + 1; $params = substr($input["params"], $params_pos); $channel = substr($input["params"], 0, strpos($input["params"], " ")); call_user_func($hook["function"], $this->irc, $params, $input["prefix"], $channel); } } } } } ?>