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() { $Vote = new Vote($this->db); $user_vote_total = $Vote->getVoteTotalForUserInChat($this->Message->User, $this->Message->Chat->id); $user_vote_from = $Vote->getUserVotesInChat($this->Message->User, $this->Message->Chat->id); $out = "You're on *{$user_vote_total}*. "; if (count($user_vote_from) > 0) { $out .= "You've voted as follows:"; $thumbs_up = emoji(0x1f44d); $thumbs_down = emoji(0x1f44e) . emoji(0x1f3ff); foreach ($user_vote_from as $userVote) { $emoji = $userVote->vote == VoteType::Up ? $thumbs_up : $thumbs_down; $out .= "\n` `• " . $emoji . " *" . ($userVote->voted_for ? $userVote->voted_for->getName() : 'uhoh') . "* "; } } else { $out .= "You haven't cast any votes."; } $out .= "\nYou can see the voting leaderboard with /vote"; Telegram::talk($this->Message->Chat->id, $out); }
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; }
public function getTileEmoji($reveal = false) { if ($reveal) { if ($this->mine) { return emoji(0x1f4a5); } if ($this->number == 0) { return emoji(0x2b1c); } return emoji(0x30 + $this->number) . emoji(0xfe0f) . emoji(0x20e3); } if ($this->revealed && $this->mine) { return emoji(0x1f4a5); } if ($this->revealed && $this->number == 0) { return emoji(0x2b1c); } if ($this->revealed) { return emoji(0x30 + $this->number) . emoji(0xfe0f) . emoji(0x20e3); } if ($this->flagged) { return emoji(0x1f6a9); } return emoji(0x2b1b); }
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 getRecentLogsText() { $logs = $this->SQL->RetrieveRecentLogs('5'); $out = ""; if (!empty($logs)) { $logs = array_slice($logs, 0, 4); foreach ($logs as $i) { $date = date('D jS g:iA', strtotime($i['date'])); $out .= "\n`" . $date . "` \n` `" . emoji(0x27a1) . " *"; if ($i->type == TransactionType::Manual) { $out .= $i->user_sending . "* "; } elseif ($i->type == TransactionType::TransactionTax || $i->type == TransactionType::AllTax) { $out .= COIN_TAXATION_BODY . "* collected "; } elseif ($i->type == TransactionType::RedistributionTax) { $out .= COIN_REDISTRIBUTION_BODY . "* redistributed "; } if ($i->type == TransactionType::Manual) { $out .= " (" . round($i->amount, 2) . " " . $i->user_receiving->user_name . " tax)"; } elseif ($i->type == TransactionType::TransactionTax || $i->type == TransactionType::AllTax) { $out .= round($i->amount, 2) . " in tax"; } elseif ($i->type == TransactionType::RedistributionTax) { $out .= round($i->amount, 2) . " of *" . COIN_TAXATION_BODY . "'s* wealth"; } elseif (strcmp($i->user_receiving->user_name, COIN_TAXATION_BODY)) { $out .= 'sent ' . round($i->amount, 2) . " to *" . $i->user_receiving->user_name . "*"; } else { $out .= 'donated ' . round($i->amount, 2) . " to *" . $i->user_receiving->user_name . "*"; } } } else { $out .= "No recent transactions found."; } return $out; }
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 display() { if ($this->minesweeper->game->state == GameState::Lose) { $this->state = 'lose'; } if ($this->minesweeper->game->state == GameState::Win) { $this->state = 'win'; } if (strcmp($this->state, 'surrender') === 0) { $this->out = "You surrendered. Game over!"; $this->keyboard = $this->minesweeper->getBoard(true); $this->keyboard[] = [['text' => emoji(0x21a9) . " Play again", 'callback_data' => "/minesweeper"]]; } elseif (strcmp($this->state, 'lose') === 0) { $this->out = "Boom! Game over."; $this->keyboard = $this->minesweeper->getBoard(true); $this->keyboard[] = [['text' => emoji(0x21a9) . " Play again", 'callback_data' => "/minesweeper"]]; } elseif (strcmp($this->state, 'win') === 0) { $this->out = "Victory! You uncovered all the non-mined tiles."; $this->keyboard = $this->minesweeper->getBoard(true); $this->keyboard[] = [['text' => emoji(0x21a9) . " Play again", 'callback_data' => "/minesweeper"]]; } elseif (strcmp($this->state, 'reveal_mode') === 0) { $this->out = "Click mode: *uncover mine*"; $this->keyboard = $this->minesweeper->getBoard(); $this->keyboard[] = [['text' => emoji(0x1f6a9) . " Toggle Flags ON", 'callback_data' => "/minesweeper flag_mode"], ['text' => emoji(0x1f6aa) . " Surrender", 'callback_data' => "/minesweeper surrender"]]; } else { $this->out = "Click mode: *place flag*"; $this->keyboard = $this->minesweeper->getBoard(); $this->keyboard[] = [['text' => emoji(0x1f6a9) . " Toggle Flags OFF", 'callback_data' => "/minesweeper reveal_mode"], ['text' => emoji(0x1f6aa) . " Surrender", 'callback_data' => "/minesweeper surrender"]]; } }
protected function emoji($text) { if (defined('STRICT_TYPES') && CAMEL_CASE == '1') { return (string) self::parameters(['text' => DT::STRING])->call(__FUNCTION__)->with($text)->returning(DT::STRING); } else { return (string) emoji($text); } }
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 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 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); }
function t_roll($text, $chat_id) { $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); talk($chat_id, $text); return true; } } talk($chat_id, sprintf('%09d', $out)); return true; }
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() { $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); }
/** * 微信指令 错误回复 * @return string */ function wx_success($contentStr, $is_json) { $text_tpl = '<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[%s]]></Content> </xml>'; $time = time(); $contentStr = empty($is_json) ? $contentStr : json_encode($contentStr); $contentStr = "[得意]:成功咯!\n" . emoji($contentStr); $resultStr = sprintf($text_tpl, session('from'), session('to'), $time, $contentStr); echo $resultStr; die; }
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 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() { 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; }
public function main() { $ribbon = emoji(0x1f380); $santa = emoji(0x1f385); $baub_yellow = emoji(0x1f315); $baub_black = emoji(0x1f311); $baub_red = emoji(0x1f534); $baub_blue = emoji(0x1f535); $out = ''; $out .= $santa . $santa . ".` `" . emoji(0x2b50) . "\n"; $out .= $santa . $santa . ".` `" . $this->tree(2) . "\n"; $out .= ".` `" . $this->tree(2) . $baub_blue . "\n"; $out .= ".` `" . $this->tree(1) . $baub_red . $this->tree(2) . "\n"; $out .= ".` `" . $this->tree(1) . $baub_yellow . $this->tree(1) . $baub_yellow . $this->tree(1) . "\n"; $out .= ".` `" . $this->tree(1) . $ribbon . $this->tree(2) . $ribbon . $this->tree(1) . "\n"; $out .= ".` `" . $this->tree(3) . $baub_red . $this->tree(1) . $baub_blue . $this->tree(1) . "\n"; $out .= ".``" . $this->tree(8) . "\n"; $out .= ".``" . $this->present(8) . "\n"; $out .= "*M E R R Y C H R I S T M A S*"; Telegram::talk($this->Message->Chat->id, $out); }
public function main() { Telegram::sendChatTypingStatus($this->Message->Chat->id); if ($this->isParam()) { if (in_array($this->getParam(), \GroupBot\Brains\Weather\Weather::$locations)) { $city = $this->getParam(); } else { Telegram::talk($this->Message->Chat->id, "I don't have that city on record, fam.\nTry an Australian capital city."); return false; } } else { $city = 'perth'; } $realtime = \GroupBot\Brains\Weather\Weather::realtime($city); $uv = \GroupBot\Brains\Weather\Weather::uv_index($city); $sunrise = \GroupBot\Brains\Weather\Weather::sunrise($city); $forecast = \GroupBot\Brains\Weather\Weather::forecast($city); $today = $forecast[Carbon::today()->format('l')]; $tomorrow = $forecast[Carbon::tomorrow()->format('l')]; $today_icon = \GroupBot\Brains\Weather\Weather::$icon_map[$today['forecast_icon_code']]; $tomorrow_icon = \GroupBot\Brains\Weather\Weather::$icon_map[$tomorrow['forecast_icon_code']]; $out = emoji(0x1f321) . " Weather for *" . $realtime->name . "*, *" . $realtime->state . "*." . "\n" . "\n" . emoji($today_icon) . " *Now:*" . "\n` `• It's currently *" . $realtime->air_temp . "°C*" . "\n` `• The UV index is at *" . $uv->value . "* ([" . $uv->description . "](http://www.arpansa.gov.au/uvindex/realtime/images//per_rt.gif))" . "\n" . "\n" . emoji($today_icon) . " *Today:*" . "\n` `• " . $today['forecast'] . "\n` `• Maximum of *" . $today['air_temperature_maximum'] . "°C*" . "\n` `• *" . $today['probability_of_precipitation'] . "* chance of rain" . "\n` `• Sunrise is at *{$sunrise->sunrise}* today, and sunset at *{$sunrise->sunset}*" . "\n" . "\n" . emoji($tomorrow_icon) . " *Tomorrow:*" . "\n` `• " . $tomorrow['forecast'] . "\n` `• Minimum of *" . $tomorrow['air_temperature_minimum'] . "°C*, maximum of *" . $tomorrow['air_temperature_maximum'] . "°C*" . "\n` `• *" . $tomorrow['probability_of_precipitation'] . "* chance of rain"; Telegram::talk($this->Message->Chat->id, $out, true); }
if ($cw['image'] != "NO") { echo '<img src="' . $cw['image'] . '">'; } else { echo '<img src="' . $cw['image_pre'] . '">'; } // TEMPLATE IMAGE PROFILE IF USER DON'T HAVE IMAGE ?> </div><div class="cw_last"><?php if (!empty($cw['last'])) { echo $cw['last'] . "<br>"; } // LAST CONECTION (UTC/GMT +1 hour) ?> </div><div class="cw_status"><?php if (!empty($cw['status'])) { echo emoji(urldecode($cw['status'])) . "<br>"; } // STATUS TEXT WITH EMOJI DECODE OR USE urldecode($cw['status']) FOR PLAIN TEXT ?> </div><?php } else { if ($cw['result'] == "N") { echo '<div class="cw_nowhatsapp">Sorry, that number don\'t uses WhatsApp"</div>'; // THAT NUMBER DON'T USE WHATSAPP } } } else { // ERROR CONTROL echo "ERROR => " . $cw['error'] . "<br>"; if ($cw['response'] == '5') { echo $cw['timeout'] . "<br>";
protected function setMenu() { $clcikmenumodel = M('Clickmenu'); //获取微信菜单JSON $menujson = $clcikmenumodel->where(array('id' => I('id')))->getField('postmenu'); ///emoji表情解析 $menujson = emoji($menujson); $access_token = $this->getToken(); $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $menujson); $output = curl_exec($ch); curl_close($ch); $JR = json_decode($output); $rea = $JR->errmsg; if ($rea['errcode'] == 0) { $clcikmenumodel->where(array('id' => I('id')))->save(array('status' => 1)); $clcikmenumodel->where(array('id' => array('neq', I('id'))))->save(array('status' => 0)); $this->success('设置微信自定义菜单成功!'); } else { $this->error('设置微信自定义菜单失败!错误代码:' . $rea['errcode'] . '错误提示:' . $rea['errmsg']); } }
$tmpArr = $acsii = array(); $s = ''; array(); $strToArray = str_split($str); foreach ($strToArray as $i => $v) { if ($i % 2 == 0) { if (isset($strToArray[$i + 1])) { $s = dechex(ord($strToArray[$i])) . dechex(ord($strToArray[$i + 1])); //var_dump($s); if (in_array($s, $filter)) { $index = $i / 2; if ($index != 0) { $tmpArr = array($index => $s); array_push($acsii, $tmpArr); //will push string index and HEX code. } } } } } $newStr = $str; foreach ($acsii as $asi) { foreach ($asi as $k => $v) { $newStr = str_replace(cnsubstr($str, $k + 1, 1), "\\&\\#" . $v, $newStr); } } return $newStr; } $nis = "你好hello"; echo emoji($nis) . "<hr>";
private function greetUser() { if ($this->Message->Chat->no_spam_mode) { return false; } if ($this->Message->User->welcome_sent) { return false; } Telegram::talk($this->Message->Chat->id, emoji(0x1f4ef) . " Arise, *" . $this->Message->User->getName() . "*." . "\n\nYou have risen from squalor to become a " . $this->Message->User->getLevelAndTitle() . "." . "\nYou find *" . $this->Message->User->getBalance() . " " . COIN_CURRENCY_NAME . "* in a money bag on your person." . "\n\nBest of luck, brave traveller. Use /help to get started."); $this->Message->User->welcome_sent = true; $this->Message->User->save($this->db); return true; }
public function main() { if ($this->Message->isCallback()) { $this->players = $this->select_game($this->Message->message_id); if ($this->isParam() && strcmp($this->getParam(), 'button') === 0) { if (!$this->isPlayerInGame($this->Message->User->user_id)) { $this->buttonClicked($this->Message->message_id, $this->Message->User); $this->display(); $this->generateKeyboard(); 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; }
/** * @param \PDO $db * @param Chat $chat * @param $name * @return \GroupBot\Types\User|string */ public static function getUserMatchingStringOrErrorMessage(\PDO $db, Chat $chat, $name) { $userSQL = new User($db); $userInChat = true; if (isset($chat)) { if (!($user_receiving = $userSQL->getUsersInChatWithName($chat, $name))) { if (!($user_receiving = $userSQL->getUsersWithName($name))) { return emoji("0x1F44E") . " Can't find any users matching `" . $name . "`, brah"; } $userInChat = false; } } else { if (!($user_receiving = $userSQL->getUsersWithName($name))) { return emoji("0x1F44E") . " Can't find any users matching `" . $name . "`, brah"; } $userInChat = false; } if (count($user_receiving) > 1) { $out = "There are " . count($user_receiving) . " users matching that name" . ($userInChat ? " in this chat:" : ":"); foreach ($user_receiving as $user) { $out .= "\n` `•` " . $user->getNameLevelAndTitle(); } $out .= "Please redefine your query"; return $out; } return $user_receiving[0]; }