function cmd_send($command) { global $socket; $code = fputs($socket, $command . "\n\r"); global $nick; global $output; global $rawOutput; $ircMsg = new ircMsg(":" . $nick . "!" . $nick . "@plz.rewt.me " . $command); $command = strtolower($ircMsg->getCommand()); if ($rawOutput == TRUE && $output == TRUE && $command == "privmsg") { echo $nick . "!" . $nick . "@plz.rewt.me " . $command . "\n"; } elseif ($output == TRUE && $rawOutput == FALSE && $command == "privmsg") { global $modules; $modules->hook("smartOutput", array('command' => $command, 'message' => $ircMsg)); } return $code; }
$modules = new modules(); $operators = array(); $reqCommand = ""; $updateInterval = 30; $nextUpdate = time() + $updateInterval; $socket = fsockopen($server, $port); cmd_send("USER " . $nick . " " . $nick . " " . $nick . " : " . $nick); // Register user data. cmd_send("NICK " . $nick); // Change nick. cmd_send("JOIN " . $channel); // Join default channel. while (1) { while (!feof($socket)) { $data = fgets($socket); $pingCheck = substr($data, 0, strlen("PING :")); if ($pingCheck == "PING :") { $pong = substr($data, strlen("PING :")); cmd_send("PONG :" . $pong); } else { $message = new ircMsg($data); $command = strtolower($message->getCommand()); $modules->hook($command, $message); } $time = time(); if ($time >= $nextUpdate) { $modules->hook("periodic", NULL); $nextUpdate = $time + $updateInterval; } } }
// Register user data. cmd_send("NICK " . $nick); // Change nick. cmd_send("JOIN " . $channel); // Join default channel. while (1) { while ($data = fgets($socket)) { $pingCheck = substr($data, 0, strlen("PING :")); if ($pingCheck == "PING :") { // Play ping-pong. $pong = substr($data, strlen("PING :")); cmd_send("PONG :" . $pong); } elseif (!empty($data)) { $message = new ircMsg($data); if ($output && $rawOutput == FALSE) { $smartData = array('command' => strtolower($message->getCommand()), 'message' => $message); $modules->hook('smartOutput', $smartData); } elseif ($output == TRUE) { echo $data; } $command = trim(strtolower($message->getCommand())); if ($command == "privmsg") { // First part of this is ensuring that the user/channel isn't on the ignore list. $parameters = $message->getParameters(); $preWhere = trim($parameters[0]); if ($preWhere == $message->getNick()) { $where = $message->getNick(); } else { $where = $parameters[0]; } $chanSearch = array_search($where, $quietArray);