Exemple #1
0
$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;
        }
    }
}
Exemple #2
0
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);
                $nickSearch = array_search($message->getNick(), $quietArray);