Exemple #1
0
 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;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 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;
 }
 public function main()
 {
     if (!$this->Message->Chat->isPrivate()) {
         $this->group_status();
         Telegram::talk($this->Message->Chat->id, $this->out);
         return true;
     }
     $this->out = '';
     if ($this->isParam()) {
         switch ($this->getParam()) {
             case 'name':
                 $this->change_name();
                 break;
             case 'chat':
                 if ($this->noParams() == 2) {
                     $DbChat = new \GroupBot\Database\Chat($this->db);
                     if ($this->chat = $DbChat->getChatById($this->getParam(1))) {
                         $this->chat_options(false);
                         break;
                     }
                 }
                 $this->all_options();
                 break;
             case 'chatset':
                 if ($this->noParams() == 4) {
                     $DbChat = new \GroupBot\Database\Chat($this->db);
                     if ($this->chat = $DbChat->getChatById($this->getParam(1))) {
                         if ($this->set_option($this->getParam(2), $this->getParam(3))) {
                             $this->chat_options(true);
                         } else {
                             $this->chat_options(false);
                         }
                         break;
                     }
                 }
                 $this->all_options();
                 break;
             case 'yandex':
                 break;
             default:
                 $this->all_options();
         }
     } else {
         $this->all_options();
     }
     if ($this->Message->isCallback()) {
         Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $this->out, $this->keyboard);
     } else {
         Telegram::talk_inline_keyboard($this->Message->Chat->id, $this->out, $this->keyboard);
     }
     return true;
 }
Exemple #6
0
 public function main()
 {
     if ($this->Message->Chat->isPrivate()) {
         $this->chat = NULL;
     } else {
         $this->chat = $this->Message->Chat;
     }
     if ($this->noParams() == 2) {
         if (strcmp($this->getParam(), '_view_chat') === 0) {
             $DbChat = new \GroupBot\Database\Chat($this->db);
             if ($this->chat = $DbChat->getChatById($this->getParam(1))) {
                 $out = $this->displayLeaderboard();
                 $out .= $this->displayInstructions();
             } else {
                 $out = emoji(0x1f44e) . " Can't find that chat, displaying the Global Leaderboard instead.\n\n";
                 $this->chat = NULL;
                 $out .= $this->displayLeaderboard();
                 $out .= $this->displayInstructions();
             }
         } else {
             $out = $this->performVote();
             //$out .= $this->displayLeaderboard();
             $out .= $this->displayInstructions();
         }
     } else {
         $out = $this->displayLeaderboard();
         $out .= $this->displayInstructions();
     }
     if ($this->Message->Chat->isPrivate()) {
         if ($this->Message->isCallback()) {
             Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $out, $this->keyboard);
         } else {
             Telegram::talk_inline_keyboard($this->Message->Chat->id, $out, $this->keyboard);
         }
     } else {
         Telegram::talk($this->Message->Chat->id, $out);
     }
     return true;
 }
 public function main()
 {
     $this->minesweeper = new \GroupBot\Brains\Minesweeper\Minesweeper($this->db, $this->Message->Chat);
     $this->out = '';
     if ($this->isParam()) {
         if ($this->noParams() == 2) {
             $this->parseCommand($this->getParam(), $this->getParam(1));
         } elseif ($this->noParams() == 1) {
             $this->parseCommand($this->getParam());
         }
     } else {
         $this->display();
     }
     if ($this->Message->isCallback()) {
         Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $this->out, $this->keyboard);
     } else {
         Telegram::talk_inline_keyboard($this->Message->Chat->id, $this->out, $this->keyboard);
     }
     return true;
 }
Exemple #8
0
 public function main()
 {
     $this->Todo = new \GroupBot\Brains\Todo\Todo($this->db);
     if ($this->noParams() == 2 && $this->Todo->SQL->check_if_todo_exists($this->getParam()) && $this->checkVote($this->getParam(1))) {
         $out = $this->performVote($this->getParam(), $this->getParam(1), $this->Message->User);
     } elseif ($this->noParams() > 3) {
         $out = $this->addTodo($this->getAllParams(), $this->Message->User);
     } else {
         $out = $this->displayLeaderboard();
         $out .= $this->displayInstructions();
     }
     if ($this->Message->Chat->isPrivate()) {
         if ($this->Message->isCallback()) {
             Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $out, $this->keyboard);
         } else {
             Telegram::talk_inline_keyboard($this->Message->Chat->id, $out, $this->keyboard);
         }
     } else {
         Telegram::talk($this->Message->Chat->id, $out);
     }
     return true;
 }
Exemple #9
0
 public function main()
 {
     $this->out = '';
     if (!$this->Message->Chat->isPrivate()) {
         $this->group_chat();
         Telegram::talk($this->Message->Chat->id, $this->out);
         return true;
     }
     if ($this->isParam()) {
         switch ($this->getParam()) {
             case 'help':
                 $this->help();
                 break;
             case 'commands':
                 $this->commands();
                 break;
             case 'games':
                 $this->games();
                 break;
             case 'games_help':
                 $this->games_help();
                 break;
             case 'votes':
                 $this->votes();
                 break;
             case 'reminders':
                 $this->reminders();
                 break;
             case 'economy':
                 $this->economy();
                 break;
             case 'translation':
                 $this->translation();
                 break;
             case 'business':
                 $this->business();
                 break;
             default:
                 $this->main_menu();
         }
     } else {
         $this->main_menu();
     }
     if ($this->Message->isCallback()) {
         Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $this->out, $this->keyboard);
     } else {
         Telegram::talk_inline_keyboard($this->Message->Chat->id, $this->out, $this->keyboard);
     }
     return true;
 }
 public function main()
 {
     $this->getChat();
     if ($users = $this->getUsers()) {
         if ($this->global) {
             $out = "*Global* leaderboard:\n";
             $out .= $this->getTextLeaderboard($users);
         } else {
             $out = "Leaderboard for *" . $this->chat->title . "*:\n";
             $out .= $this->getTextLeaderboard($users);
         }
     } else {
         $out = "Can't find any users, brah";
     }
     if ($this->Message->Chat->isPrivate()) {
         $out .= "\nYou can also view these recent group chat leaderboards:";
         if ($this->Message->isCallback()) {
             Telegram::edit_inline_message($this->Message->Chat->id, $this->Message->message_id, $out, $this->keyboard());
         } else {
             Telegram::talk_inline_keyboard($this->Message->Chat->id, $out, $this->keyboard());
         }
     } else {
         Telegram::talk($this->Message->Chat->id, $out);
     }
 }