當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::getInput方法代碼示例

本文整理匯總了PHP中Longman\TelegramBot\Request::getInput方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getInput方法的具體用法?PHP Request::getInput怎麽用?PHP Request::getInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Longman\TelegramBot\Request的用法示例。


在下文中一共展示了Request::getInput方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * 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();
 }
開發者ID:noplanman,項目名稱:php-telegram-bot,代碼行數:17,代碼來源:Telegram.php

示例2: handle

 /**
  * 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;
     }
 }
開發者ID:TAOOAT,項目名稱:php-telegram-bot,代碼行數:51,代碼來源:Telegram.php

示例3: handle

 /**
  * 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;
     }
 }
開發者ID:nodir-y,項目名稱:php-telegram-bot,代碼行數:64,代碼來源:Telegram.php

示例4: handle

 /**
  * 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);
     }
 }
開發者ID:aniston,項目名稱:php-telegram-bot,代碼行數:22,代碼來源:Telegram.php

示例5: handle

 /**
  * 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;
     }
 }
開發者ID:Bizkaitarra,項目名稱:pintxobot,代碼行數:60,代碼來源:Telegram.php


注:本文中的Longman\TelegramBot\Request::getInput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。