getInput() публичный статический Метод

Set input from custom input or stdin and return it
public static getInput ( ) : string
Результат string
Пример #1
0
 /**
  * Handle bot request from webhook
  *
  * @return bool
  */
 public function handle()
 {
     $this->input = Request::getInput();
     if (empty($this->input)) {
         throw new TelegramException('Input is empty!');
     }
     $post = json_decode($this->input, true);
     if (empty($post)) {
         throw new TelegramException('Invalid JSON!');
     }
     return $this->processUpdate(new Update($post, $this->bot_name))->isOk();
 }
Пример #2
0
 /**
  * Handle bot request
  *
  * @return \Longman\TelegramBot\Telegram
  */
 public function handle()
 {
     $this->input = Request::getInput();
     if (empty($this->input)) {
         throw new TelegramException('Input is empty!');
     }
     $post = json_decode($this->input, true);
     if (empty($post)) {
         throw new TelegramException('Invalid JSON!');
     }
     $update = new Update($post, $this->bot_name);
     $this->insertRequest($update);
     $message = $update->getMessage();
     // check type
     $type = $message->getType();
     switch ($type) {
         default:
         case 'text':
             // do nothing
             break;
         case 'command':
             // execute command
             $command = $message->getCommand();
             return $this->executeCommand($command, $update);
             break;
         case 'new_chat_participant':
             // trigger new participant
             $command = 'new_chat_participant';
             return $this->executeCommand($command, $update);
             break;
         case 'left_chat_participant':
             // trigger left chat participant
             $command = 'left_chat_participant';
             return $this->executeCommand($command, $update);
             break;
         case 'new_chat_title':
             // trigger new_chat_title
             break;
         case 'delete_chat_photo':
             // trigger delete_chat_photo
             break;
         case 'group_chat_created':
             // trigger group_chat_created
             break;
     }
 }
Пример #3
0
 /**
  * Handle bot request
  *
  * @return \Longman\TelegramBot\Telegram
  */
 public function handle()
 {
     $this->input = Request::getInput();
     if (empty($this->input)) {
         throw new TelegramException('Input is empty!');
     }
     $post = json_decode($this->input, true);
     if (empty($post)) {
         throw new TelegramException('Invalid JSON!');
     }
     $update = new Update($post, $this->bot_name);
     //Load admin Commands
     if ($this->admin_enabled) {
         $message = $update->getMessage();
         //$from = $message->getFrom();
         //$user_id = $from->getId();
         //Admin command avaiable only in single chat with the bot
         $chat = $message->getChat();
         $user_id = $chat->getId();
         if (in_array($user_id, $this->admins_list)) {
             $this->addCommandsPath(BASE_PATH . '/Admin');
         }
     }
     $this->insertRequest($update);
     $message = $update->getMessage();
     // check type
     $type = $message->getType();
     switch ($type) {
         default:
         case 'text':
             // do nothing
             break;
         case 'command':
             // execute command
             $command = $message->getCommand();
             return $this->executeCommand($command, $update);
             break;
         case 'new_chat_participant':
             // trigger new participant
             return $this->executeCommand('Newchatparticipant', $update);
             break;
         case 'left_chat_participant':
             // trigger left chat participant
             return $this->executeCommand('Leftchatparticipant', $update);
             break;
         case 'new_chat_title':
             // trigger new_chat_title
             return $this->executeCommand('Newchattitle', $update);
             break;
         case 'delete_chat_photo':
             // trigger delete_chat_photo
             return $this->executeCommand('Deletechatphoto', $update);
             break;
         case 'group_chat_created':
             // trigger group_chat_created
             return $this->executeCommand('Groupchatcreated', $update);
             break;
     }
 }
Пример #4
0
 /**
  * Handle bot request
  *
  * @return \Longman\TelegramBot\Telegram
  */
 public function handle()
 {
     $this->input = Request::getInput();
     if (empty($this->input)) {
         throw new TelegramException('Input is empty!');
     }
     $post = json_decode($this->input, true);
     if (empty($post)) {
         throw new TelegramException('Invalid JSON!');
     }
     $update = new Update($post, $this->bot_name);
     $this->insertRequest($update);
     $command = $update->getMessage()->getCommand();
     if (!empty($command)) {
         return $this->executeCommand($command, $update);
     }
 }
Пример #5
0
 /**
  * Handle bot request
  *
  * @return \Longman\TelegramBot\Telegram
  */
 public function handle()
 {
     $this->input = Request::getInput();
     if (empty($this->input)) {
         throw new TelegramException('Input is empty!');
     }
     $post = json_decode($this->input, true);
     if (empty($post)) {
         throw new TelegramException('Invalid JSON!');
     }
     $update = new Update($post, $this->bot_name);
     $this->insertRequest($update);
     $message = $update->getMessage();
     // check type
     $type = $message->getType();
     switch ($type) {
         default:
         case 'text':
             // do nothing
             $chat_id = $message->getChat()->getId();
             $message_id = $message->getMessageId();
             $text = $message->getText();
             //Si estamos en modo test
             $test = new Test();
             $datatest = $test->realizarAccionesTest($message);
             if (!is_null($datatest)) {
                 return Request::sendMessage($datatest);
             } else {
                 // do nothing
             }
             break;
         case 'command':
             // execute command
             $command = $message->getCommand();
             return $this->executeCommand($command, $update);
             break;
         case 'new_chat_participant':
             // trigger new participant
             return $this->executeCommand('Newchatparticipant', $update);
             break;
         case 'left_chat_participant':
             // trigger left chat participant
             return $this->executeCommand('Leftchatparticipant', $update);
             break;
         case 'new_chat_title':
             // trigger new_chat_title
             break;
         case 'delete_chat_photo':
             // trigger delete_chat_photo
             break;
         case 'group_chat_created':
             // trigger group_chat_created
             break;
     }
 }