function talk($where, $message) { $array = explode("\n", $message); foreach ($array as $msg) { cmd_send("PRIVMSG " . $where . " :" . $msg); } }
$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; } } }
//<?php return function ($message) { global $nick; $parameters = $message->getParameters(); if ($parameters[1] == $nick) { cmd_send("JOIN :" . $parameters[0]); } };
//<?php return function ($message) { global $registered; $params = $message->getParameters(); if (!empty($params[1])) { $text = trim($params[1]); if ($registered == TRUE && $message->getNick() == "NickServ" && $text == "If you do not change within one minute, I will change your nick.") { global $NSpassword; cmd_send("PRIVMSG NickServ :IDENTIFY " . $NSpassword); } } return true; };
if (!$initiated) { global $dbUsername; global $dbPassword; global $dbHostname; global $dbDatabase; $dbc = mysqli_connect($dbHostname, $dbUsername, $dbPassword, $dbDatabase); if ($dbc) { $query = mysqli_query($dbc, "SELECT * FROM lectures WHERE time > " . time() . " ORDER BY time ASC LIMIT 1"); $rows = mysqli_num_rows($query); if ($rows > 0) { while ($array = mysqli_fetch_array($query)) { // Countdown $timestamp = $array['time'] - time(); // A lot of the below is overly complicated fail math.... fyi. <3 $days = (int) round($timestamp / 86400, 0); $hours = (int) round(($timestamp - $days * 86400) / 3600, 0); $minutes = (int) round(($timestamp - ($hours * 3600 + $days * 86400)) / 60, 0); talk($where, "There is one upcomimg lecture on '" . $array['title'] . "' by " . $array['lecturers'] . " in " . $days . " days, " . $hours . " hours, and " . $minutes . " minutes.\nDescription: " . $array['description'] . "\nLink: http://www.hackthissite.org/forums/" . $array['link']); } } else { talk($where, "There are no upcoming lectures! Sorry. :("); } } else { say("ERROR: Could not connect to database."); cmd_send("NOTICE " . $message->getNick() . " :An error has occured. Please try again later."); } } else { cmd_send("NOTICE " . $message->getNick() . " :There is currently a lecture."); } } };