示例#1
0
 function isTriggered()
 {
     if (!isset($this->data['text'])) {
         $this->printUsage();
         return;
     }
     switch ($this->data['trigger']) {
         case '!translate':
             $sl = 'auto';
             $tl = $this->getConfig('language');
             break;
         default:
             $trigger = substr($this->data['trigger'], 1);
             list($sl, $tl) = explode('-', $trigger);
             break;
     }
     if (false === ($translation = libInternet::googleTranslate($this->data['text'], $sl, $tl, $sl == 'auto' ? true : false))) {
         $this->reply("Something weird occurred ");
         return;
     }
     if ($sl == 'auto') {
         $this->reply("Translation from " . $translation['source_lang'] . ": " . $translation['translation']);
     } else {
         $this->reply("Translation: " . $translation);
     }
 }
示例#2
0
 function isTriggered()
 {
     if (!isset($this->data['text'])) {
         $this->printUsage();
         return;
     }
     $input = explode(',', $this->data['text']);
     if (empty($input[1])) {
         $this->reply(sprintf($this->usage, $this->data['trigger']));
         return;
     }
     $terms = array();
     for ($i = 0; $i < 2; $i++) {
         $terms[$i] = trim($input[$i]);
         if (str_word_count($terms[$i]) == 1) {
             $terms[$i] = '"' . $terms[$i] . '"';
         }
     }
     $word1Hits = libInternet::googleResults($terms[0]);
     $word2Hits = libInternet::googleResults($terms[1]);
     if ($word1Hits + $word2Hits == 0) {
         $zero = array('zero', 'oh', 'null', 'nil', 'nought');
         $this->reply('I can\'t compare ' . $zero[rand(0, 4)] . ' with ' . $zero[rand(0, 4)] . '.');
         return;
     }
     $this->reply('(' . number_format($word1Hits, 0, ',', '.') . ") " . $input[0] . " " . $this->getBar($word1Hits, $word2Hits) . " " . $input[1] . " (" . number_format($word2Hits, 0, ',', '.') . ")");
 }
示例#3
0
 function isTriggered()
 {
     if (!isset($this->data['text'])) {
         $this->printUsage();
         return;
     }
     $this->reply(sprintf('%s (Results: %s)', "http://www.google.com/search?q=" . urlencode($this->data['text']) . "&hl=" . $this->getConfig('language') . "&safe=off", number_format(libInternet::googleResults($this->data['text']), 0, ',', '.')));
 }
示例#4
0
 function onChannelMessage()
 {
     if (false === ($id = libInternet::youtubeID($this->data['text']))) {
         return;
     }
     if (false === ($data = libInternet::getYoutubeData($id))) {
         return;
     }
     $this->reply(sprintf("[YouTube] Title: %s | Rating: %.2f/5.00 | Views: %s", $data['title'], $data['rating'], number_format($data['views'])));
 }
示例#5
0
 function isTriggered()
 {
     if (!isset($this->data['text'])) {
         $this->printUsage();
         return;
     }
     $tinyurl = libInternet::tinyURL($this->data['text']);
     if (strlen($tinyurl) <= strlen($this->data['text'])) {
         $this->reply($tinyurl);
     } else {
         $this->reply($tinyurl . ' - Now your URL is even longer than before - Good job!');
     }
 }
示例#6
0
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $this->sendOutput("Usage: " . $this->info['triggerUsed'] . " text");
         return;
     }
     $trigger = substr($this->info['triggerUsed'], 1);
     $tmp = explode("-", $trigger);
     $sl = $tmp[0];
     $tl = $tmp[1];
     $translation = libInternet::googleTranslate($this->info['text'], $sl, $tl);
     $translation = preg_replace_callback('/\\\\u([0-9a-f]{4})/', create_function('$m', 'return chr(hexdec($m[1]));'), $translation);
     $translation = $this->unhtmlentities($translation);
     $this->sendOutput("Translation: " . $translation);
 }
示例#7
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);
     }
 }
示例#8
0
文件: Google.php 项目: noother/Nimda2
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $this->sendOutput(sprintf($this->CONFIG['no_term'], $this->info['triggerUsed']));
         return;
     }
     $link = "http://www.google.com/search?q=" . urlencode($this->info['text']) . "&hl=" . $this->CONFIG['lang'] . "&safe=off";
     $results = number_format(libInternet::googleResults($this->info['text']), 0, ',', '.');
     $output = $link . " (Results: ";
     if (!$results) {
         $output .= "0";
     } else {
         $output .= "~ ";
     }
     $output .= $results . ")";
     $this->sendOutput($output);
 }
示例#9
0
文件: Vs.php 项目: noother/Nimda2
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $this->sendOutput(sprintf($this->CONFIG['no_term'], $this->info['triggerUsed']));
         return;
     }
     $input = explode(",", $this->info['text']);
     if ($input[1] == "") {
         $this->sendOutput(sprintf($this->CONFIG['no_term'], $this->info['triggerUsed']));
         return;
     }
     $word1Hits = libInternet::googleResults($input[0]);
     $word2Hits = libInternet::googleResults($input[1]);
     if ($word1Hits + $word2Hits == 0) {
         $zero = array("zero", "oh", "null", "nil", "nought");
         $this->sendOutput("I can't compare " . $zero[rand(0, 4)] . " with " . $zero[rand(0, 4)] . ".");
         return;
     }
     $this->sendOutput("(" . number_format($word1Hits, 0, ',', '.') . ") " . $input[0] . " " . $this->getBar($word1Hits, $word2Hits) . " " . $input[1] . " (" . number_format($word2Hits, 0, ',', '.') . ")");
 }
示例#10
0
文件: Tv.php 项目: noother/Nimda2
 function isTriggered()
 {
     $program = libInternet::getTvProgram();
     $stations = explode(',', $this->CONFIG['stations']);
     $output = array();
     $current = 0;
     $output[0] = "[Current TV Program] ";
     foreach ($stations as $station) {
         $save = $output[$current];
         $output[$current] .= "" . $station . ": " . $program[$station]['title'] . ", ";
         if (strlen($output[$current]) > 450) {
             $output[$current] = substr($save, 0, -2);
             $current++;
             $output[$current] = "" . $station . ": " . $program[$station]['title'] . ", ";
         }
     }
     $output[$current] = substr($output[$current], 0, -2);
     foreach ($output as $line) {
         $this->sendOutput($line);
     }
 }
示例#11
0
文件: Omegle.php 项目: Laxa/Nimda3
 private function checkSpam($text)
 {
     $links = libString::getUrls($text);
     foreach ($links as $link) {
         $parts = parse_url($link);
         if ($parts['host'] == 'tinyurl.com' && isset($parts['path']) && !isset($path['query']) && ctype_alnum(substr($parts['path'], 1))) {
             if ($this->checkSpam(libInternet::tinyURLDecode($link))) {
                 return true;
             }
         } else {
             preg_match('/[^\\.]+\\.[^\\.]+$/', $parts['host'], $arr);
             $domain = $arr[0];
             if (in_array($domain, self::$bannedHosts)) {
                 return true;
             }
         }
     }
     return false;
 }
示例#12
0
 function addWord($word)
 {
     $old_word = $word;
     $word = libString::convertUmlaute($word);
     $word = libString::capitalize($word);
     if (preg_match("/[^a-zA-Z]/", $word)) {
         $this->sendOutput("Your word must contain only letters.");
         return;
     }
     $sql = "SELECT id FROM hangman WHERE word='" . addslashes($word) . "'";
     $res = $this->MySQL->sendQuery($sql);
     if ($res['count'] != 0) {
         $this->sendOutput("This word is already in the database.");
         return;
     }
     $google_results = libInternet::googleResults($old_word);
     if ($google_results < $this->CONFIG['google_min']) {
         //$output = sprintf($this->CONFIG['googlemin_text'],
         //					$this->CONFIG['google_min']
         //				 );
         $this->sendOutput($this->CONFIG['googlemin_text']);
         return;
     }
     $blacklist = array("add", "del", "stats", "start", "stop");
     if (array_search(strtolower($word), $blacklist) !== false) {
         $this->sendOutput("Stuuuuupiiid!");
         return;
     }
     $sql = "INSERT INTO\n\t\t\t\t\thangman\n\t\t\t\t\t(word, author, created)\n\t\t\t\tVALUES (\n\t\t\t\t\t'" . addslashes($word) . "',\n\t\t\t\t\t'" . addslashes($this->info['nick']) . "',\n\t\t\t\t\tNOW()\n\t\t\t\t)";
     $this->MySQL->sendQuery($sql);
     $this->sendOutput("Word '" . $word . "' has been added to the database.");
     return;
 }