$cmd_msg = assemble($args, 3); $cmd_target = $privmsg_target; $this->loadCommandInfo(); if (empty($chan_key) && array_key_exists($cmd_target, $this->users) && $this->users[$cmd_target]->isBot()) { $bot = $this->users[$cmd_target]; $is_private = true; } if (!empty($chan_key) && $cmd_msg[0] == '!') { $cmd_msg = substr($cmd_msg, 1); $bot = $this->default_bot; $is_public = true; } if ($is_public || $is_private) { $user_numeric = $args[0]; $user = $this->getUser($user_numeric); $pargs = lineGetArgs($cmd_msg, false); $cmd_name = strtolower($pargs[0]); $last_char = substr($cmd_msg, strlen($cmd_msg) - 1); $is_ctcp = $cmd_name[0] == CTCP_START && $last_char == CTCP_END; if ($is_ctcp) { $cmd_msg = trim($cmd_msg, CTCP_START . CTCP_END); $cmd_name = trim($cmd_name, CTCP_START . CTCP_END); $cmd_name = "ctcp_" . $cmd_name; } elseif (!$user->isOper()) { $bot->noticef($user, "You must be a global operator to use this service."); return false; } $spoofed_ctcp = !$is_ctcp && substr($cmd_name, 0, 5) == 'ctcp_'; $cmd_handler_file = CMD_HANDLER_DIR . $cmd_name . '.php'; if (($this->commandExists($cmd_name) || $is_ctcp) && file_exists($cmd_handler_file) && !$spoofed_ctcp) { $user_level = $this->getUserLevel($user);
function parse($line) { $num_args = lineNumArgs($line); $args = lineGetArgs($line); if ($args[0] == 'PASS' || $args[0] == 'SERVER' || $args[0] == 'NOTICE' || $args[0] == 'ERROR') { $token = $args[0]; } else { $token = $args[1]; } $handler_file = "handle_{$token}.php"; $core_handler = P10_DIR . $handler_file; $service_handler = SERVICE_HANDLER_DIR . $handler_file; $chan_key = ''; $chan_name = ''; $bot = false; for ($i = 0; $i < count($args); ++$i) { if ($args[$i][0] == '#') { $chan_name = $args[$i]; $chan_key = strtolower($chan_name); break; } } if ($num_args >= 3 && !(($bot = $this->getUser($args[2])) && $bot->isBot())) { $bot = $this->default_bot; } if (file_exists($core_handler)) { include $core_handler; } if (file_exists($service_handler)) { include $service_handler; } // TODO: Breaks everything; slated for 1.3 or 2.0 //$core_result = $this->handlerContainer($core_handler, true, $num_args, $args, $chan_name, $chan_key, $bot); //$service_result = $this->handlerContainer($service_handler, false, $num_args, $args, $chan_name, $chan_key, $bot); //return $core_result && $service_result; return true; }