public function execute($message) { $cmd = $message->getCommand(); global $api; $this->gc = new GoogleCache(); switch ($cmd) { case "g": $lines = array(); $res = $this->search(implode(" ", $message->getData())); foreach ($res as $id => $result) { $lines[] = "*" . $id . " - " . Google::bToUS($result["title"]) . "*"; $lines[] = Google::bToUS($result["content"]); $lines[] = "(" . Google::encodeUs($result["url"]) . ")"; $lines[] = ""; } $api->sendMessage($message->chat->id, implode("\n", $lines), "Markdown", true); break; case "img": $data = $this->img(implode(" ", $message->getData())); $id = mt_rand(0, sizeof($data["items"]) - 1); $api->sendPhoto($message->chat->id, $data["items"][$id]["link"], implode(" ", $message->getData())); break; } }