Exemplo n.º 1
0
 public function privmsg($message, $bypass_queue = false)
 {
     if (isset($this->modes['c'])) {
         $message = libIRC::stripControlChars($message);
     }
     parent::privmsg($message, $bypass_queue);
 }
Exemplo n.º 2
0
 function showRanking()
 {
     $luvs = $this->getVar('luvs');
     if (!$luvs) {
         $this->reply('There are no luvs yet.');
         return;
     }
     usort($luvs, array('self', 'sortByLuvs'));
     $top10 = array();
     for ($i = 0; $i < 10 && $i < sizeof($luvs); $i++) {
         $top10[] = libIRC::noHighlight($luvs[$i]['nick']) . ' (' . sizeof($luvs[$i]['luvs']) . ')';
     }
     $this->reply('Popularity ranking: ' . implode(', ', $top10));
 }
Exemplo n.º 3
0
 function onChannelMessage()
 {
     if (!isset($this->interpreters[$this->Server->id . ':' . $this->Channel->id])) {
         return;
     }
     foreach ($this->interpreters[$this->Server->id . ':' . $this->Channel->id] as $lang) {
         $translation = libInternet::googleTranslate($this->data['text'], 'auto', $lang);
         if (empty($translation)) {
             continue;
         }
         if (strtolower($translation) == strtolower($this->data['text'])) {
             continue;
         }
         $this->reply('<' . libIRC::noHighlight($this->User->nick) . '> ' . $translation);
     }
 }
Exemplo n.º 4
0
 private function printStats($global = false)
 {
     $serverchannel = addslashes($this->Server->id . ':' . $this->Channel->id);
     $sql = "\n\t\t\tSELECT\n\t\t\t\tSUM(`started`) AS `played`,\n\t\t\t\tSUM(`clicks`) + SUM(`lost`) AS `shots`,\n\t\t\t\tCOUNT(*) AS `playercount`\n\t\t\tFROM\n\t\t\t\t`roulette`\n\t\t";
     if (!$global) {
         $sql .= "\n\t\t\t\tWHERE\n\t\t\t\t\t`serverchannel` = '" . $serverchannel . "'\n\t\t\t";
     }
     $stats = $this->MySQL->fetchRow($sql);
     if (!$stats['playercount']) {
         $this->reply('No games have been played yet.');
         return;
     }
     $sql = "SELECT\n\t\t\t\t\t`nick`,\n\t\t\t\t\t`clicks` / (`clicks`+`lost`) * 100 AS `percentage`\n\t\t\t\tFROM\n\t\t\t\t\t`roulette`\n\t\t\t\tWHERE\n\t\t\t";
     if (!$global) {
         $sql .= "`serverchannel` = '" . $serverchannel . "' AND ";
     }
     $sql .= "`played` >= 10\n\t\t\t\tGROUP BY\n\t\t\t\t\t`nick`\n\t\t\t\tORDER BY\n\t\t\t\t\t`percentage` DESC\n\t\t\t\t";
     $res = $this->MySQL->query($sql);
     if (empty($res)) {
         $luckiest = array('nick' => 'no one', 'percentage' => 100);
         $unluckiest = array('nick' => 'no one', 'percentage' => 0);
     } else {
         $luckiest = $res[0];
         $unluckiest = array_pop($res);
     }
     $this->reply(sprintf("Roulette %sstats: %s completed, %s fired at %s. Luckiest: %s (%.2f%% clicks). Unluckiest: %s (%.2f%% clicks).", $global ? "global" : "", libString::plural('game', $stats['played']), libString::plural('shot', $stats['shots']), libString::plural('player', $stats['playercount']), libIRC::noHighlight($luckiest['nick']), $luckiest['percentage'], libIRC::noHighlight($unluckiest['nick']), $unluckiest['percentage']));
 }
Exemplo n.º 5
0
 private function printStats()
 {
     if (!$this->getVar('stats_games_completed')) {
         $this->reply('No one has ever played the game.');
         return;
     }
     $max_players = $this->getVar('stats_max_players');
     foreach ($max_players['players'] as &$player) {
         $player = libIRC::noHighlight($player);
     }
     $max_points = $this->getVar('stats_max_points');
     $ranking = $this->getVar('ranking');
     $top5 = array();
     for ($i = 0; $i < 5 && $i < sizeof($ranking); $i++) {
         $top5[] = libIRC::noHighlight($ranking[$i]['nick']) . ' (' . $ranking[$i]['won'] . ')';
     }
     $top5 = implode(', ', $top5);
     $this->reply(sprintf("%s %s been completed. The largest game ever was played by %d players (%s) on %s. The highest sum ever was achieved by %s on %s with %d points. Top5: %s", libString::plural('dice game', $this->getVar('stats_games_completed')), libString::plural('have', $this->getVar('stats_games_completed')), $max_players['count'], implode(', ', $max_players['players']), date('Y-m-d H:i:s', $max_players['date']), libIRC::noHighlight($max_points['nick']), date('Y-m-d H:i:s', $max_points['time']), $max_points['points'], $top5));
 }