public function execute($message) { $markdown = true; global $t; $t->setPlugin("wikipedia"); $cmd = strtolower($message->getCommand()); $data = $message->getData(); $cmd_params = explode("_", $cmd); if (sizeof($cmd_params) == 2) { $param = $cmd_params[1]; $cmd = $cmd_params[0]; } switch ($cmd) { case "wiki": if (sizeof($data) >= 1) { $title = implode(" ", $data); } else { $help = $t->g("default"); $help = implode("\n", $help); Api::reply($message->chat, $help, true); return; } $wp = new WikipediaParser(); $text = $wp->search($title, strtolower(LANGUAGE)); $markdown = false; break; case "wikip": $wp = new WikipediaParser(); $text = $wp->page($param, strtolower(LANGUAGE)); break; } Api::reply($message->chat, $text, $markdown); }
public function execute($message) { global $pluginManager; global $t; $t->setPlugin("help"); $cmd = $message->getCommand(); $data = explode("_", $cmd); array_shift($data); $help = trim(implode(" ", $data)); $reply = ""; if (empty($help)) { $res = $pluginManager->getPluginList(); $helps = array(); foreach ($res as $text) { $helps[] = $text . " - /help\\_" . $text; } $res = $helps; array_unshift($res, "*" . $t->g("available") . "*"); } else { $plugin = $pluginManager->getPlugin($help); $res = $pluginManager->getHelp($plugin); if (sizeof($res) == 0) { $res = array("*" . sprintf($t->g("notfound"), $help) . "*"); } else { $helps = array(); foreach ($res as $text) { $helps[] = str_replace("_", "\\_", $text); } array_unshift($helps, "*" . sprintf($t->g("helpheader"), $help, $plugin) . "*"); $res = $helps; } } $reply = implode("\n", $res); Api::reply($message->chat, $reply, true); }
public function execute($message) { $joke = file_get_contents("http://www.witzcharts.de/witz.php?witz=zufall"); $joke = str_replace('document.write("', "", $joke); $joke = str_replace("<br><a href='http://www.witzcharts.de' target='_blank'>witzcharts.de</a>\");", "", $joke); $joke = str_replace("<br />", "\n", $joke); $joke = html_entity_decode($joke); Api::reply($message->chat, $joke); }
public function receive($message) { if ($message->type == "location") { $forecast = false; $coords = array("lon" => $message->location->longitude, "lat" => $message->location->latitude); $wp = new WeatherParser($coords); Api::reply($message->chat, $wp->getWeather($forecast), true); } }
public function execute($message) { global $api; $cmd = strtolower($message->getCommand()); $meme = new MemeApi(); $data = $message->getData(); $cmd_params = explode("_", $cmd); if (count($cmd_params) > 1) { switch ($cmd_params[1]) { case "list": if (count($cmd_params) > 2) { $str = $meme->listMemes($cmd_params[2]); } else { $str = $meme->listMemes(); } Api::reply($message->chat, $str, true); return; break; case "search": $str = $meme->searchMemes($data); Api::reply($message->chat, $str, true); return; break; } } $std_meme = "One Does Not Simply"; $std_text_top = "One Does Not Simply"; $std_text_bottom = "Use No Parameters"; $data = implode(" ", $data); $args = explode(";", $data); $num = count($args); if ($num == 1 && $args[0] == "") { $num = 0; } switch ($num) { case 0: $res = $meme->get($std_meme, $std_text_top, $std_text_bottom); break; case 1: $res = $meme->get($args[0], "", ""); break; case 2: $res = $meme->get($args[0], $args[1], ""); break; default: $res = $meme->get($args[0], $args[1], $args[2]); break; } if ($res === false) { Api::reply($message->chat, "Huuuups", false); } else { $api->sendPhoto($message->chat, $res); // Api::sendImg($chat, file_get_contents($res), "meme.jpg"); //Api::reply($message, $res, false); } }
public function execute($message) { $cmd = $data[0]; $data = $message->getData(); $cmd = explode($message->getCommand(), "_"); if (sizeof($cmd) > 1) { Api::reply($message, "Hier fehlt noch was"); } elseif (sizeof($data) > 0) { // ("/news SUCHE BEGRIFFE") $spiegel = new Spiegel(); $topics = $spiegel->search($data, true); if (!$topics) { Api::reply($message->chat, "Keine News zu diesen Begriffen"); } else { $msg = array(); $msg[] = '*Suchergebnisse zu "' . implode(", ", $data) . '":*'; foreach ($topics as $topic) { $msg[] = ""; $msg[] = "*" . $topic["title"] . "*"; $msg[] = $topic["description"]; $msg[] = "[Zum Artikel](" . $topic["link"] . ")"; } Api::reply($message->chat, implode("\n", $msg), true); } } else { // List topics ("/news" $spiegel = new Spiegel(); $topics = $spiegel->getLastTopics(); if (!$topics) { Api::reply($message->chat, "Derzeit keine News"); } else { $msg = array(); $msg[] = "*Aktuelle Themen:*"; foreach ($topics as $topic) { $msg[] = ""; $msg[] = "*" . $topic["title"] . "*"; $msg[] = $topic["description"]; $msg[] = "[Zum Artikel](" . $topic["link"] . ")"; } Api::reply($message->chat, implode("\n", $msg), true); } } }
public function execute($message) { $cmd = strtolower($message->getCommand()); $data = $message->getData(); $params = array("format" => "plaintext"); $wa = new WolframAlphaEngine(WOLFRAM_API_KEY); $res = $wa->getResults(implode(" ", $data), $params); file_put_contents("log/wolfram.log", json_encode($res)); $sol = array(); if ($res->isError()) { Api::reply($message, "Da kann ich leider nichts mit anfangen...", false); return; } if (count($res->getPods()) > 0) { foreach ($res->getPods() as $pod) { if ($pod->attributes["id"] == "Solution") { $sol[] = "*Ergebnisse für " . implode(" ", $data) . "*:"; foreach ($pod->getSubpods() as $solution) { $sol[] = api::encodePlain($solution->plaintext); } } elseif ($pod->attributes["id"] == "ComplexSolution") { $sol[] = "*Komplexe Ergebnisse für " . implode(" ", $data) . "*:"; foreach ($pod->getSubpods() as $solution) { $sol[] = api::encodePlain($solution->plaintext); } } elseif ($pod->attributes["id"] == "Result") { $sol[] = "*Ergebnis für " . implode(" ", $data) . "*:"; foreach ($pod->getSubpods() as $solution) { $sol[] = api::encodePlain($solution->plaintext); } } } } if (sizeof($sol) == 0) { $sol[] = "Leider keine Ergebnisse :("; } Api::reply($message->chat, implode("\n", $sol), true); }