Exemple #1
0
 function isTriggered()
 {
     $uptime = libTime::secondsToString(time() - $this->IRCBot->startTime);
     $res = $this->MySQL->query("SELECT SUM(seconds) total FROM uptime");
     $total_uptime = time() - $this->IRCBot->startTime + $res['result'][0]['total'];
     $this->sendOutput("Uptime: " . $uptime . ' - Total Uptime: ' . libTime::secondsToString($total_uptime));
 }
Exemple #2
0
 private function assembleText($data)
 {
     $text = 'I\'ve last seen ' . $data['nick'] . ' ' . libTime::secondsToString(time() - $data['time']) . ' ago ';
     if ($data['server'] != $this->Server->host) {
         $text .= 'on ' . $data['server'] . ' ';
     }
     switch ($data['action']) {
         case 'ACTION':
             $text .= 'in ' . $data['channel'] . ' stating that he ' . $data['text'] . '.';
             break;
         case 'PRIVMSG':
             $text .= 'in ' . $data['channel'] . ' saying "' . $data['text'] . '".';
             break;
         case 'JOIN':
             $text .= 'joining ' . $data['channel'] . '.';
             break;
         case 'PART':
             $text .= 'parting ' . $data['channel'];
             if ($data['message'] !== false) {
                 $text .= ' with message ' . $data['message'] . '.';
             } else {
                 $text .= '.';
             }
             break;
         case 'QUIT':
             $text .= 'quitting the server with message "' . $data['message'] . '".';
             break;
     }
     return $text;
 }
Exemple #3
0
 function getStats($username, $html)
 {
     if (strpos($html, 'There is no available information for') !== false) {
         return false;
     }
     preg_match('#<h3>User information of (VIP )?(.*?)</h3>#', $html, $arr);
     $nick = $arr[2];
     # inactive users will match the username regex with ' ' but there are no details about them, so return false then
     if (!preg_match('#<b>Rank:</b>.*?<font color=".*?">(.*?)</font>#', $html, $arr)) {
         return false;
     }
     $rank = $arr[1];
     preg_match('#<b>Number of hacks:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $solved = $arr[1];
     preg_match('#<b>Rankpoints:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $rankpoints = $arr[1];
     preg_match('#<b>Visited:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $visited = $arr[1];
     preg_match('#<b>Time spent overall:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $timeSpent = $arr[1];
     preg_match('#<b>Last online:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $lastOnline = trim($arr[1]);
     $data = array('username' => $nick, 'user_title' => $rank, 'challs' => $solved, 'score' => $rankpoints, 'visits' => $visited, 'time' => libTime::secondsToString($timeSpent), 'last_online' => $lastOnline);
     return $data;
 }
Exemple #4
0
 function onJoin()
 {
     $info = $this->info;
     $lChannel = strtolower($info['channel']);
     if (!isset($this->peaks[$lChannel])) {
         $this->peaks[$lChannel] = array('users' => 0, 'time' => 0);
         $this->MySQL->query("INSERT INTO channel_peaks (channel, users, date) VALUES ('" . addslashes($lChannel) . "', 0, '" . time() . "')");
     }
     $users = $this->IRCBot->getUsers($info['channel']);
     if (!$users) {
         return;
     }
     $users = sizeof($users);
     if ($users > $this->peaks[$lChannel]['users']) {
         $oldpeak = array();
         $oldpeak['users'] = $this->peaks[$lChannel]['users'];
         $oldpeak['time'] = $this->peaks[$lChannel]['time'];
         $this->peaks[$lChannel]['users'] = $users;
         $this->peaks[$lChannel]['time'] = time();
         $this->MySQL->query("UPDATE channel_peaks SET users='" . $users . "', date='" . time() . "' WHERE channel='" . addslashes($lChannel) . "'");
         if ($oldpeak['users'] == 0) {
             return;
         }
         $this->sendOutput(sprintf($this->CONFIG['text_newpeak'], $info['channel'], $users, $oldpeak['users'], date('Y-m-d H:i:s', $oldpeak['time']), libTime::secondsToString(time() - $oldpeak['time'])), $info['channel']);
     }
 }
Exemple #5
0
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $nick = $this->info['nick'];
     } else {
         $nick = $this->info['text'];
     }
     $domain = $this->CONFIG['domain'];
     $get = sprintf($this->CONFIG['get'], urlencode($nick));
     $result = libHTTP::GET($domain, $get);
     $result = implode($result['content'], "\n");
     if (preg_match("/There is no available information for/", $result)) {
         $this->sendOutput(sprintf($this->CONFIG['doesnt_exist'], $nick, $this->CONFIG['domain']));
         return;
     }
     preg_match('#<h3>User information of (VIP )?(.*?)</h3>#', $result, $arr);
     $nick = $arr[2];
     preg_match('#<b>Rank:</b>.*?<font color=".*?">(.*?)</font>#', $result, $arr);
     $rank = $arr[1];
     preg_match('#<b>Donated:</b>.*?<font color=".*?">(.*?)</font>#', $result, $arr);
     $donated = $arr[1];
     if ($donated == "This guy didn't donate anything yet!") {
         $donated = false;
     } else {
         $donated = str_replace(" ", "", $donated);
     }
     preg_match('#<b>Number of hacks:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $solved = $arr[1];
     preg_match('#<b>Rankpoints:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $rankpoints = $arr[1];
     preg_match('#<b>Visited:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $visited = $arr[1];
     preg_match('#<b>Time spent overall:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $timeSpent = $arr[1];
     preg_match('#<b>Last online:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $lastOnline = trim($arr[1]);
     preg_match('#<b>User\'s current status:</b>.*?<td>(.*?)</td>#', $result, $arr);
     if ($arr[1] == "offline") {
         $online = false;
     } else {
         $online = true;
     }
     $output = sprintf($this->CONFIG['text_status'], $nick, $rank, $solved, libString::end_s("challenge", $solved), $rankpoints);
     $output .= " ";
     $output .= sprintf($this->CONFIG['text_visit'], $nick, $this->CONFIG['domain'], $visited, libTime::secondsToString($timeSpent));
     if ($donated) {
         $output .= " ";
         $output .= sprintf($this->CONFIG['text_donate'], $nick, $donated);
     }
     $output .= " ";
     if ($online) {
         $output .= sprintf($this->CONFIG['text_online'], $nick, $domain);
     } else {
         $output .= sprintf($this->CONFIG['text_lastonline'], $nick, $lastOnline);
     }
     $this->sendOutput($output);
 }
Exemple #6
0
 function onJoin()
 {
     $user_count = sizeof($this->Channel->users);
     if ($user_count > $this->Channel->getVar('peak')) {
         if ($this->getConfig('peakshow') === 'yes') {
             $this->reply(sprintf("New channel peak for %s: %d users online. Old one was %d users online at %s (%s ago)", $this->Channel->name, $user_count, $this->Channel->getVar('peak'), $this->Channel->getVar('peak_date'), libTime::secondsToString(libTime::getSecondsDifference(date('r'), $this->Channel->getVar('peak_date')))));
         }
         $this->Channel->saveVar('peak', $user_count);
         $this->Channel->saveVar('peak_date', date('Y-m-d H:i:s'));
     }
 }
Exemple #7
0
 function isTriggered()
 {
     $uptime = libTime::secondsToString($this->Bot->time - $this->started);
     $servercount = sizeof($this->Bot->servers);
     $channelcount = 0;
     $usercount = 0;
     foreach ($this->Bot->servers as $Server) {
         $channelcount += sizeof($Server->channels);
         $usercount += sizeof($Server->users);
     }
     $mem_current = number_format(memory_get_usage() / 1000000, 2);
     $mem_peak = number_format(memory_get_peak_usage() / 1000000, 2);
     $this->reply(sprintf("Uptime: %s. Memory: %.2f MB (%.2f MB max). SQL: %d queries total (%.2f q/s). Jobs: %d (%d max). Timers: %d. Servers: %d, Channels: %d, Users: %d. ", $uptime, $mem_current, $mem_peak, $this->MySQL->queryCount, $this->MySQL->queryCount / ($this->Bot->time - $this->started), $this->Bot->jobCount, $this->Bot->jobCountMax, $this->Bot->timerCount, $servercount, $channelcount, $usercount));
 }
Exemple #8
0
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $this->sendOutput("Usage: " . $this->info['triggerUsed'] . " nick");
         return;
     }
     $nick = addslashes($this->info['text']);
     $res = $this->MySQL->sendQuery("SELECT * FROM seen WHERE nick='" . $nick . "'");
     if ($res['count'] == 0) {
         $this->sendOutput("I don't know " . $nick . ".");
         return;
     }
     $data = $res['result'][0];
     switch ($data['action']) {
         case "PRIVMSG":
             $action = "saying";
             break;
     }
     $text = sprintf($this->CONFIG['text'], $data['nick'], libTime::secondsToString(time() - strtotime($data['last_update'])), $data['channel'], $action, $data['text']);
     $this->sendOutput($text);
 }
Exemple #9
0
 function isTriggered()
 {
     $this->reply(sprintf("Uptime: %s - Total Uptime: %s", libTime::secondsToString($this->Bot->time - $this->started), libTime::secondsToString($this->getVar('total_uptime', 0) + $this->Bot->time - $this->started)));
 }
Exemple #10
0
 private function printPlayerStats($nick)
 {
     $ranking = $this->getVar('ranking', array());
     $stats = false;
     if (preg_match('/[^0-9]/', $nick)) {
         foreach ($ranking as $index => $rank) {
             if ($rank['nick'] == $nick) {
                 $stats = $rank;
                 $stats['rank'] = $index + 1;
                 break;
             }
         }
         if ($stats === false) {
             $this->reply($nick . ' has never played dice.');
             return;
         }
     } else {
         if (isset($ranking[$nick - 1])) {
             $stats = $ranking[$nick - 1];
             $stats['rank'] = $nick;
         } else {
             $this->reply("No one is on that rank.");
             return;
         }
     }
     $text = sprintf("%s has played %s, won %d and lost %d. %s is on rank %d of %d. %s's last game was %s ago.", $stats['nick'], libString::plural('game', $stats['played']), $stats['won'], $stats['played'] - $stats['won'], $stats['nick'], $stats['rank'], sizeof($ranking), $stats['nick'], libTime::secondsToString(time() - $stats['last_played']));
     if ($stats['rank'] != 1) {
         $text .= sprintf(" %s needs to win %s to rankup.", $stats['nick'], libString::plural('more game', $ranking[$stats['rank'] - 2]['won'] - $stats['won'] + 1));
     }
     $this->reply($text);
 }