Example #1
0
 private function getChat()
 {
     if ($this->Message->Chat->isPrivate()) {
         $DbChat = new Chat($this->db);
         if ($this->isParam() && ($this->chat = $DbChat->getChatById($this->getParam()))) {
             return true;
         }
         $this->chat = NULL;
         $this->global = true;
     } else {
         $this->chat = $this->Message->Chat;
     }
     return true;
 }
Example #2
0
 private function all_options()
 {
     $DbChat = new Chat($this->db);
     $this->out .= emoji(0x2699) . " Hi *" . $this->Message->User->getName() . "*." . "\n\nYou can access the following personal preferences:" . "\n`   `• Change how your name is displayed";
     $this->keyboard = [[['text' => 'Change name', 'callback_data' => '/preferences name']]];
     if ($chats = $DbChat->getChatsByAdmin($this->Message->User->user_id)) {
         $this->out .= "\n" . "\nYou're my admin for the following chats:";
         $keyboard = [];
         foreach ($chats as $index => $chat) {
             $this->out .= "\n`   `• `" . $chat->title . "`";
             $keyboard[] = ['text' => $chat->title, 'callback_data' => '/preferences chat ' . $chat->id];
             if ($index != 0 && $index % 4 == 0) {
                 $this->keyboard[] = $keyboard;
                 $keyboard = [];
             }
         }
         if (isset($keyboard)) {
             $this->keyboard[] = $keyboard;
         }
         $this->out .= "\n" . "\nPlease click on a chat name below to change its settings.";
     }
     $this->keyboard[] = [['text' => emoji(0x1f6aa) . ' Back to main menu', 'callback_data' => '/help']];
 }
Example #3
0
 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;
 }