public function main() { $Vote = new Vote($this->db); $leaderboard = $Vote->getVoteLeaderboard($this->Message->Chat->id); $out = ''; $index = 0; if (!empty($leaderboard)) { foreach ($leaderboard as $uservote) { $index++; $out .= "`" . $this->addOrdinalNumberSuffix($index); if ($index >= 10) { $out .= " `"; } else { $out .= " `"; } $vote_prefix = $uservote->vote_total > 0 ? "+" : ""; if (!isset($uservote->vote_total)) { $uservote->vote_total = 0; } $out .= "*" . $uservote->user->getName() . "* (" . $vote_prefix . $uservote->vote_total . ")\n"; } } else { $out .= "No users to display."; } Telegram::talk($this->Message->Chat->id, $out); }
public function main() { if ($this->Message->text == 'dubs') { $no = mt_rand(0, 9); Telegram::talk($this->Message->Chat->id, "`" . str_repeat($no, 9) . "`"); return true; } $q = explode("d", trim($this->Message->text)); if (count($q) == 2 && is_numeric($q[0]) && is_numeric($q[1])) { $no = intval($q[0]); $sides = intval($q[1]); if ($no < 0 || $sides < 0 || $no > 50 || $sides > 999999999) { Telegram::talk($this->Message->Chat->id, "naw brah"); return false; } $out = array_map("mt_rand", array_fill(0, $no, 1), array_fill(0, $no, $sides)); $out = implode(", ", $out); Telegram::talk($this->Message->Chat->id, "`" . $out . "`"); } else { $out = mt_rand(0, 999999999); $dubs = array(9 => "nines", 8 => "eights", 7 => "sevens", 6 => "sixes", 5 => "quints", 4 => "quads", 3 => "trips", 2 => "dubs"); foreach ($dubs as $key => $value) { $test = substr(strval($out), 0 - $key); if (preg_match('/^(.)\\1*$/', $test)) { $text = str_repeat(emoji(0x1f389), $key - 1) . "`" . sprintf('%09d', $out) . "`" . "\nnice " . $value . " brah" . str_repeat("!", $key - 1); Telegram::talk($this->Message->Chat->id, $text); return true; } } Telegram::talk($this->Message->Chat->id, "`" . sprintf('%09d', $out) . "`"); } return true; }
public function main() { if ($this->isParam() && $this->noParams() > 2) { $params = explode(' to ', $this->getAllParams(), 2); if (count($params) == 2) { try { $date_due = Carbon::parse($params[0]); $reminder = new Reminder(); $reminder->construct($this->Message->User->user_id, $this->Message->Chat->id, Carbon::now()->toDateTimeString(), $date_due->toDateTimeString(), $params[1]); $ReminderControl = new Control($this->db); $ReminderControl->addReminder($reminder); $diff = $date_due->diffForHumans(Carbon::now(), true); $out = emoji(0x23f2) . " Okay, I've scheduled a reminder in *{$diff}*."; if ($date_due->diffInMinutes(Carbon::now()) < 60) { $out .= "\n\nBy the way, I only send out notifications once a minute."; } Telegram::talk($this->Message->Chat->id, $out); return true; } catch (\Exception $e) { // nada } } } $out = emoji(0x270d) . " Like this fam: " . "\n" . "\n` `• `/remind` *+2 hours* `to` *pick up the milk*" . "\n` `• `/remind` *2:25PM 26th April* `to` *look out the window*" . "\n` `• `/remind` *tomorrow 5PM* `to` *go outside*" . "\n` `• `/remind` *monday 2AM* `to` *go to sleep*" . "\n" . "\nMy timezone is *GMT+8*, and it's now *" . date('g:i A') . "* on the *" . date('jS') . "*."; Telegram::talk($this->Message->Chat->id, $out); return true; }
private function startBot($debug) { if (isset($debug)) { $update = $debug; } else { $content = file_get_contents("php://input"); $update = json_decode($content, true); } if (!$update) { return false; } // Telegram::talkForced('56390227', print_r($update, true)); // return true; if (isset($update["message"])) { $this->processMessage($update['message']); } elseif (isset($update["inline_query"])) { $this->InlineQuery = new InlineQuery($update["inline_query"]); Telegram::answerInlineQuery($this->InlineQuery->id, $this->InlineQuery->results); } elseif (isset($update["callback_query"])) { $message = $update["callback_query"]["message"]; $message['from'] = $update["callback_query"]["from"]; $message['text'] = $update["callback_query"]["data"]; $message['callback'] = true; $this->processMessage($message); } return true; }
public function main() { $RussianRoulette = new RussianRoulette($this->db, $this->Message->Chat->id, $this->Message->User->user_id); $RussianRoulette->reload(); $out = emoji(0x1f52b) . " `Revolver reloaded.`" . "\n" . "\nThere are *six* chambers, and *one* bullet." . "\nUse /trigger to play."; Telegram::talk($this->Message->Chat->id, $out); }
public function main() { $Transact = new Transact($this->db); if ($this->noParams() == 2) { $user_receiving = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam()); if (is_string($user_receiving)) { Telegram::talk($this->Message->Chat->id, $user_receiving); return false; } $Transaction = new Transaction($this->Message->User, $user_receiving, $this->getParam(1), new TransactionType(TransactionType::Manual)); $Transact->performTransaction($Transaction); if ($Feedback = $Transact->Feedback->getFeedback()) { $out = emoji("0x1F4E2") . " " . $Feedback . "\n` `• `" . $user_receiving->getName() . "` now has 💰*" . $user_receiving->getBalance() . "*" . "\n` `• `You've` got 💰*" . $this->Message->User->getBalance() . "* left."; if ($user_receiving->user_id != -1) { $out .= "\n` `• `The Bank` took 2%, or 💰*" . round($this->getParam(1) * 0.02, 2) . "*"; } Telegram::talk($this->Message->Chat->id, $out); } else { Telegram::talk($this->Message->Chat->id, "I'm so sorry brah..."); } } else { Telegram::talk($this->Message->Chat->id, "Like this fam " . emoji("0x1F449") . " /send richardstallman 10"); } return true; }
public function q_echo() { if ($this->Message->isText()) { Telegram::talk($this->Message->Chat->id, ">not understanding echo"); } else { Telegram::talk($this->Message->Chat->id, $this->Message->text); } }
public function sendGIFThroughTelegram($file_path) { $back = \GroupBot\Telegram::sendDocument($this->chat_id, $file_path); $back = json_decode($back, true); $file_id = $back['result']['document']['file_id']; $photoSQL = new Photo($this->db); $photoSQL->addServerPhotoId($file_id, '', $file_path); }
public function s_spookyecho() { if ($this->Message->Chat->type == ChatType::Group) { Telegram::talk($this->Message->Chat->id, ">not understanding spookyecho"); } elseif (strlen($this->Message->text) == 0) { Telegram::talk($this->Message->Chat->id, ">still not understanding spookyecho"); } else { Telegram::talk('-19315940', $this->Message->text); } }
public function main() { $word = strlen($this->getAllParams()) > 10 ? substr($this->getAllParams(), 10) : $this->getAllParams(); $word = strtoupper($word); $out = implode(' ', str_split($word)); foreach (str_split(substr($word, 1)) as $char) { $out .= "\n{$char}"; } Telegram::talk($this->Message->Chat->id, "*{$out}*"); }
public function main() { $Level = new Level(); $user = $this->Message->User; $greetings = array("Arise", "Congratulations"); if ($Level->buyLevel($user, $this->db)) { $out = emoji(0x1f4ef) . " " . $greetings[mt_rand(0, count($greetings) - 1)] . " *" . $user->getName() . "*, you are now a *Level " . $user->level . " " . $user->getTitle() . "*!" . "\nYou may rise to Level " . ($user->level + 1) . " for a price of " . $Level->getLevelPrice($user->level + 1) . " Coin."; } else { $out = emoji(0x1f44e) . " Sorry, you need " . $Level->getLevelPrice($user->level + 1) . " Coin to rise to Level " . ($user->level + 1) . "."; } Telegram::talk($this->Message->Chat->id, $out); }
public static function getResponse(\PDO $db, Message $message, PlayerMove $move, $bet = NULL) { $Blackjack = new Blackjack($db, $message->User, $message->Chat, $move, $bet); if ($Blackjack->Talk->areMessages()) { $keyboard = $Blackjack->Talk->getKeyboard(); if ($message->isCallback()) { \GroupBot\Telegram::edit_inline_message($message->Chat->id, $message->message_id, $Blackjack->Talk->getMessages(), $keyboard); } else { \GroupBot\Telegram::talk_inline_keyboard($message->Chat->id, $Blackjack->Talk->getMessages(), $keyboard); } return true; } return false; }
public function main() { if ($this->Message->isCallback()) { if ($this->isParam() && strcmp($this->getParam(), 'button') === 0) { $this->out = emoji(0x1f38c) . " *WINNER!*\n\n*" . $this->Message->User->getName() . "* clicked the button!"; Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $this->out, $this->keyboard); } } else { $this->out = emoji(0x1f3c1) . " *Click the button to win!!*"; $this->generateKeyboard(); Telegram::talk_inline_keyboard($this->Message->Chat->id, $this->out, $this->keyboard); } return true; }
public function main() { if ($this->isParam()) { $user = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam()); if (is_string($user)) { Telegram::talk($this->Message->Chat->id, $user); return false; } Telegram::talk($this->Message->Chat->id, $user->getNameLevelAndTitle() . " has " . emoji("0x1F4B0") . "*" . $user->getBalance() . "*, brah"); } else { Telegram::talk($this->Message->Chat->id, "You've got " . emoji("0x1F4B0") . "*" . $this->Message->User->getBalance() . "*, brah"); } return true; }
public static function getResponse(\PDO $db, Message $message, PlayerMove $move, $bet = NULL) { $Casinowar = new Casinowar($db, $message->User, $message->Chat->id, $move, $bet); if ($Casinowar->Talk->areMessages()) { $keyboard = $Casinowar->Talk->getKeyboard(); if ($keyboard) { \GroupBot\Telegram::reply_keyboard($message->Chat->id, $Casinowar->Talk->getMessages(), $message->message_id, $keyboard); } else { \GroupBot\Telegram::talk_hide_keyboard($message->Chat->id, $Casinowar->Talk->getMessages()); } return true; } return false; }
public function s_spookyzalgoperson() { $zalgo = new Zalgo(NULL); $out = $zalgo->speak($this->Message->text); $no1 = $zalgo->speak(">not understanding spookyzalgoperson"); $no2 = $zalgo->speak(">still not understanding spookyzalgoperson"); if ($this->Message->Chat->type == ChatType::Group) { Telegram::talk($this->Message->Chat->id, $no1); } elseif (strlen($this->Message->text) == 0) { Telegram::talk($this->Message->Chat->id, $no2); } else { Telegram::talk('-19315940', person($out, false)); } }
public function main() { $this->out = emoji(0x1f4a2) . " *A great rumbling fills the earth...* " . emoji(0x1f4a2) . "\n"; if ($this->Message->User->getBalance() > 0 && $this->Message->User->level > 1) { $choices = ['loseFreeBets', 'losePopularity', 'loseAllMoney', 'dropOneLevel']; } elseif ($this->Message->User->getBalance() > 0 && $this->Message->User->level == 1) { $choices = ['loseFreeBets', 'losePopularity', 'loseAllMoney']; } elseif ($this->Message->User->getBalance() == 0 && $this->Message->User->level > 1) { $choices = ['loseFreeBets', 'losePopularity', 'dropOneLevel']; } else { $choices = ['loseFreeBets', 'losePopularity']; } $this->{$choices[mt_rand(0, count($choices) - 1)]}(); Telegram::talk($this->Message->Chat->id, $this->out); }
public function main() { $count = $this->isParam() && is_numeric($this->getParam()) ? intval($this->getParam()) : 1; if ($count < 1) { $count = 1; } if ($count > 4096) { $count = 4096; } $out = ''; for ($i = 0; $i < $count; $i++) { $out .= randomEmoji(); } Telegram::talk($this->Message->Chat->id, $out); }
public static function SendDocumentByPath(\PDO $db, $local_path, $chat_id) { $md5 = md5_file($local_path, true); if (isset($local_path)) { $photoSQL = new Photo($db); $file_id = $photoSQL->getServerPhotoId($md5, $local_path); if ($file_id !== false) { Telegram::fileIdPhotoSender($chat_id, $file_id); } else { $back = Telegram::sendDocument($chat_id, $local_path); $back = json_decode($back, true); $file_id = end($back['result']['photo'])['file_id']; $photoSQL->addServerPhotoId($file_id, $md5, $local_path); } } }
public function sendReminders() { $reminders = $this->SQL->select_reminders(); $UserDb = new User($this->db); /** @var Reminder $reminder */ foreach ($reminders as $reminder) { $date_due = Carbon::parse($reminder->date_due); $date_created = Carbon::parse($reminder->date_created); if ($date_due->lte(Carbon::now())) { $user = $UserDb->getUserFromId($reminder->user_id); $out = emoji(0x23f0) . " *" . $user->getName() . "*, your reminder from *" . $date_created->diffForHumans(Carbon::now(), true) . "* ago:" . "\n" . "\n`" . $reminder->content . "`"; Telegram::talkForced($reminder->chat_id, $out); $this->SQL->delete_reminder($reminder); } } }
public function main() { $Events = new Events($this->db); if ($Events->addIncome($this->Message->User)) { Telegram::talk($this->Message->Chat->id, emoji(0x1f4b8) . " " . $this->Message->User->getNameLevelAndTitle() . ", you received your daily allowance of `" . Level::getDailyAllowance($this->Message->User->level) . "` coin. You now have `" . $this->Message->User->getBalance() . "` coin."); } else { $now = new \DateTime(); $future_date = new \DateTime('tomorrow'); $interval = $future_date->diff($now); $time = $interval->format("*%h hours* and *%i minutes*"); $out = emoji(0x1f4e2) . " " . $this->Message->User->getNameLevelAndTitle() . "..." . "\n\n" . emoji(0x1f44e) . " You must wait {$time} until you can add to your collection of `" . $this->Message->User->getBalance() . "` coin."; //$out = emoji(0x1F44E) . " You've already received your allowance today!" // . "\nThere's still $time to go until tomorrow"; Telegram::talk($this->Message->Chat->id, $out); } }
public function main() { $Level = new \GroupBot\Brains\Level\Level(); if ($this->isParam()) { $user = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam()); if (is_string($user)) { $out = $user; } else { $out = emoji(0x1f4ef) . " Make way for " . $user->getNameLevelAndTitle() . "!"; } } else { $user = $this->Message->User; $out = emoji(0x1f4ef) . " Greetings " . $user->getNameLevelAndTitle() . "." . "\nYou may rise to level " . ($user->level + 1) . " for a price of " . $Level->getLevelPrice($user->level + 1) . " Coin." . "\nPlease use /buylevel to do this."; } Telegram::talk($this->Message->Chat->id, $out); }
public function t_wolfram() { $wolf = file_get_contents('http://www.wolframalpha.com/input/?i=' . urlencode($this->Message->text)); preg_match_all("/http:\\/\\/www.*.wolframalpha.com\\/Calculate\\/[^<>]*\\./", $wolf, $matches, PREG_SET_ORDER); $img = new Imagick(); foreach ($matches as $i) { $handle = fopen($i[0], 'rb'); $img->readImageFile($handle); } $img->resetIterator(); $combined = $img->appendImages(true); $date = new DateTime(); $path = WOLFRAM_DIR . '/img' . $date->getTimestamp() . '.gif'; $combined->writeImage($path); Telegram::customPhotoSender($this->Message->Chat->id, $path); }
public function main() { return true; //Telegram::sendChatSendingPhotoStatus($this->Message->Chat->id); $Radar = new \GroupBot\Brains\Weather\Radar\Radar($this->Message->Chat->id, $this->db); $radar_code = 70; $image_radius_code = 3; if ($this->Message->isCallback()) { $key = $this->getParam(); $radar_code = Radar_Codes::$radar_codes[$key][0]; if (!$radar_code) { Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, "Something went wrong!", []); return false; } Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, "Showing {$radar_code}", []); } elseif ($this->isParam()) { if (!($radar_code = $Radar->getRadarCodeFromString($this->getParam()))) { Telegram::talk($this->Message->Chat->id, "Can't find that location, fam"); return false; } if (is_array($radar_code)) { $keyboard = []; $row = []; foreach ($radar_code as $name) { $row[] = ['text' => $name[0] . " (" . $name[2] . ")", 'callback_data' => "/radar {$name['2']}"]; } $keyboard[] = $row; Telegram::talk_inline_keyboard($this->Message->Chat->id, "Did you mean one of these?", $keyboard); return false; } if ($this->noParams() > 1 && !($image_radius_code = $Radar->getImageRangeFromString($this->getParam(1)))) { Telegram::talk($this->Message->Chat->id, "can't find that range, fam\nusually there's `128km`, `256km` or `512km` available"); return false; } } // Acquire lock $fp = fopen('/var/www/html/bot/radar/lock', 'r+'); if (!flock($fp, LOCK_EX | LOCK_NB)) { Telegram::talk($this->Message->Chat->id, "cool it, m8\n" . emoji(0x1f914) . " i'm thinking"); return false; } // Payload $Radar->createAndSendRadarGIF($radar_code, $image_radius_code); // Release lock fclose($fp); return true; }
public function main() { $RussianRoulette = new RussianRoulette($this->db, $this->Message->Chat->id, $this->Message->User->user_id); if ($RussianRoulette->isLoaded()) { if ($RussianRoulette->trigger()) { $out = emoji(0x1f4a5) . emoji(0x1f52b) . "\n" . "\n" . emoji(0x2620) . " *" . $this->Message->User->getName() . "* killed themselves." . "\n /reload to play again."; Telegram::talkForced($this->Message->Chat->id, $out); //Telegram::kick($this->Message->Chat->id, $this->Message->User->user_id); } else { $out = $this->getFace() . emoji(0x1f52b) . " `Click.`"; Telegram::talk($this->Message->Chat->id, $out); } } else { $out = emoji(0x1f449) . " The revolver isn't loaded. Use /reload first."; Telegram::talk($this->Message->Chat->id, $out); } }
public function t_stats() { $log = new Logging($this->Message); $Coin = new Coin(); $BlackjackSQL = new SQL(); $CasinowarSQL = new \GroupBot\Brains\Casinowar\SQL(); $Level = new Level(); if ($this->isParam()) { $user_id = $log->checkIfUserIsLogged($this->getParam()); if (!$user_id) { Telegram::talk($this->Message->Chat->id, "can't find that user, brah"); return false; } } else { $user_id = $this->Message->User->id; } $log = $log->getAllUserLogsForChat($user_id); $bj_stats = $BlackjackSQL->select_player_stats($user_id); $cw_stats = $CasinowarSQL->select_player_stats($user_id); $level = $Level->SQL->get_level($user_id); $level_title = $Level->getTitle($level); $CoinUser = $Coin->SQL->GetUserById($user_id); $date = 0; foreach ($log->LogsCommand as $cmd) { if (strtotime($cmd->last_used) > $date) { $last_cmd = $cmd; $date = strtotime($cmd->last_used); } } if (!isset($last_cmd)) { return false; } $out = emoji(0x1f4c8) . "*" . $this->Message->Chat->title . "* stats for " . "\n*" . $log->User->first_name . " " . $log->User->last_name . "*, the Level *{$level}* {$level_title}" . "\n` `•` " . $log->posts_today . "` message" . $this->plural_grammar($log->posts_today) . " sent today" . "\n` `•` " . $log->posts . "` message" . $this->plural_grammar($log->posts) . " sent ever" . "\n` `•` " . round(86400 * $log->posts / (strtotime("now") - strtotime("2015-11-19 11:00:00")), 0) . "` messages sent per day, on average" . "\nLast message `(" . date('D jS g:iA', strtotime($log->lastpost_date)) . ")`:" . "\n` `_" . $log->lastpost . "_" . "\nLast command: `" . $last_cmd->command . "`" . "\n` `•` " . $last_cmd->uses_today . "` use" . $this->plural_grammar($last_cmd->uses_today) . " today" . "\n` `•` " . $last_cmd->uses . "` use" . $this->plural_grammar($last_cmd->uses_today) . " ever"; $last_coin_activity = isset($CoinUser->last_activity) ? date('D jS g:iA', strtotime($CoinUser->last_activity)) : "not recorded"; $out .= "\n\n" . emoji(0x1f4b2) . "*" . COIN_CURRENCY_NAME . "* stats:" . "\n` `•` " . $CoinUser->getBalance() . "`" . emoji(0x1f4b0) . " in the bank" . "\n` `•` " . $Coin->SQL->GetNumberOfTransactionsByUser($CoinUser) . "` outgoing transactions ever" . "\n` `•` `Last activity: `" . $last_coin_activity . "`"; if ($bj_stats) { $bj_balance = $bj_stats->coin_won - $bj_stats->coin_lost; $out .= "\n\n" . emoji(0x1f0cf) . "*Blackjack* stats:" . "\n` `•` " . $bj_stats->games_played . "` games ever with `" . $bj_stats->wins . ":" . $bj_stats->losses . ":" . $bj_stats->draws . "` _(W:L:D)_" . "\n` `•` " . $bj_stats->hits . "` hits, `" . $bj_stats->stands . "` stands, `" . $bj_stats->surrenders . "` surrenders" . "\n` `•` " . $bj_stats->splits . "` splits, `" . $bj_stats->doubledowns . "` doubledowns, `" . $bj_stats->blackjacks . "` blackjacks" . "\n` `•` " . round($bj_stats->total_coin_bet, 2) . "`" . emoji(0x1f4b0) . " bet ever, currently " . ($bj_balance == 0 ? "breaking even at `" : ($bj_balance > 0 ? "up `" : "down `")) . round($bj_balance, 2) . "`" . emoji(0x1f4b0); } if ($cw_stats) { $cw_balance = $cw_stats->coin_won - $cw_stats->coin_lost; $out .= "\n\n" . emoji(0x1f0cf) . "*Casino war* stats:" . "\n` `•` " . $cw_stats->games_played . "` games ever with `" . $cw_stats->wins . ":" . $cw_stats->losses . "` _(W:L)_" . "\n` `•` " . $cw_stats->wars . "` wars and `" . $cw_stats->surrenders . "` surrenders." . "\n` `•` " . round($cw_stats->total_coin_bet, 2) . "`" . emoji(0x1f4b0) . " bet ever, currently " . ($cw_balance == 0 ? "breaking even at `" : ($cw_balance > 0 ? "up `" : "down `")) . round($cw_balance, 2) . "`" . emoji(0x1f4b0); } Telegram::talk($this->Message->Chat->id, $out); return true; }
public function t_wiki() { if (strlen($this->Message->text) == 0) { Telegram::talk($this->Message->Chat->id, ">not understanding wiki"); return 0; } $url = 'http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exsentences=3&exintro=&explaintext=&exsectionformat=plain&titles='; $url .= urlencode($this->Message->text) . "&redirects="; $data = json_decode(file_get_contents($url)); $info = key($data->{'query'}->{'pages'}); if ($info == '-1') { Telegram::talk($this->Message->Chat->id, "doesn't exist, fam"); } else { $out = current($data->{'query'}->{'pages'})->{'extract'}; Telegram::talk($this->Message->Chat->id, $out); } return true; }
public function createAndSendRadarGIF($radar_code, $image_radius_code) { $radar_string = BoM::getBoMRadarString($radar_code, $image_radius_code); $web_image_paths = BoM::getRadarTransparencies($radar_code, $image_radius_code); $file_path = self::getNewLocalFilePath($web_image_paths); if (count($web_image_paths) < 2) { \GroupBot\Telegram::talk($this->chat_id, emoji(0x274c) . " Something went wrong getting the radar images fam. The radar might be down. Check here to see if it's working: \n \nhttp://www.bom.gov.au/products/" . $radar_string . ".loop.shtml#skip"); return false; } if (!$this->telegram->sendIfExists($file_path)) { \GroupBot\Telegram::sendChatSendingPhotoStatus($this->chat_id); ImageProcessing::createBackground($radar_string); $images = ImageProcessing::overlay($web_image_paths, $radar_string); ImageProcessing::animate($images, $file_path); $this->telegram->sendGIFThroughTelegram($file_path); } return true; }
public function main() { $jokes_file = file(__DIR__ . "/../Libraries/jokes_christmas"); $jokes = array(); $joke = ""; foreach ($jokes_file as $line) { if ($line == "\r\n") { $jokes[] = $joke; $joke = ""; continue; } $joke .= $line; } $out = $this->tree(15) . "\n"; $out .= $jokes[mt_rand(0, count($jokes) - 1)]; $out .= $this->santa(15); Telegram::talk($this->Message->Chat->id, $out); }
public function main() { if ($this->isParam() && $this->noParams() > 2) { $params = explode(' or ', $this->getAllParams()); if (count($params) > 1) { $decision = mt_rand(0, count($params) - 1); $out = emoji(0x1f44d) . " *" . $params[$decision] . "*"; Telegram::talk($this->Message->Chat->id, $out); return true; } } if (mt_rand(0, 1)) { $out = emoji(0x1f44d) . " *Yes!*"; } else { $out = emoji(0x1f44e) . " *No.*"; } Telegram::talk($this->Message->Chat->id, $out); return true; }