public function parse($data) { $data = IRC::Parse($data); // we can ignore the origin. // $origin = $data['origin']; $command = $data['command']; $params = $data['params']; // now we need to find out if there's a method in $this for handling $command // if there is, we pass off the rest of $data - the parameters - to it // for processing if (method_exists($this, "cmd_" . $command)) call_user_func(array($this, "cmd_" . $command), $params); // if there ISN'T a method for handling $command... // first we should check if they're registered. We intercept CAP entirely // and NICK at least initially, so if the user isn't registered, yell at them // like a small child that has just tried to pick up the cat by the ears. else if (!$this->isRegistered()) $this->sendNumeric(451, ":Register first"); // but if we ARE registered we should probably just be sending the data straight // along to the server, but only if we have one! else if (is_a($this->myServer, "IRCServer")) { // pull the last param off if it's freeform if ($data['freeform'] === TRUE) $freeform = array_pop($params); // then we need to rebuild our command $data = strtoupper($command) . " " . implode($params); // and if we have freeform, stick in on there. if (isset($freeform)) $data .= " :" . $freeform; // and then send it! $this->myServer->send($data); } // if we get a command we don't recognize, and AREN'T attached to a server, // then we have a problem. I see a couple options: // 1. ERR_UNKNOWNCOMMAND (421) // 2. Some server message about attaching // I'm not fully decided either way yet, but I am partial to #1 as it seems // more in line with the spirit of the IRC specification. else $this->sendNumeric(421, "%s :Unknown command", strtoupper($command)); }