当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::emptyResponse方法代码示例

本文整理汇总了PHP中Longman\TelegramBot\Request::emptyResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::emptyResponse方法的具体用法?PHP Request::emptyResponse怎么用?PHP Request::emptyResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Longman\TelegramBot\Request的用法示例。


在下文中一共展示了Request::emptyResponse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute command
  *
  * @return \Longman\TelegramBot\Entities\ServerResponse
  * @throws \Longman\TelegramBot\Exception\TelegramException
  */
 public function execute()
 {
     //If a conversation is busy, execute the conversation command after handling the message
     $conversation = new Conversation($this->getMessage()->getFrom()->getId(), $this->getMessage()->getChat()->getId());
     //Fetch conversation command if it exists and execute it
     if ($conversation->exists() && ($command = $conversation->getCommand())) {
         return $this->telegram->executeCommand($command);
     }
     return Request::emptyResponse();
 }
开发者ID:akalongman,项目名称:php-telegram-bot,代码行数:16,代码来源:GenericmessageCommand.php

示例2: execute

 /**
  * Command execute method
  *
  * @return mixed
  * @throws \Longman\TelegramBot\Exception\TelegramException
  */
 public function execute()
 {
     $message = $this->getMessage();
     $chat = $message->getChat();
     $user = $message->getFrom();
     $text = trim($message->getText(true));
     $chat_id = $chat->getId();
     $user_id = $user->getId();
     //Preparing Response
     $data = ['chat_id' => $chat_id];
     if ($chat->isGroupChat() || $chat->isSuperGroup()) {
         //reply to message id is applied by default
         //Force reply is applied by default so it can work with privacy on
         $data['reply_markup'] = Keyboard::forceReply(['selective' => true]);
     }
     //Conversation start
     $this->conversation = new Conversation($user_id, $chat_id, $this->getName());
     $notes =& $this->conversation->notes;
     !is_array($notes) && ($notes = []);
     //cache data from the tracking session if any
     $state = 0;
     if (isset($notes['state'])) {
         $state = $notes['state'];
     }
     $result = Request::emptyResponse();
     //State machine
     //Entrypoint of the machine state if given by the track
     //Every time a step is achieved the track is updated
     switch ($state) {
         case 0:
             if ($text === '') {
                 $notes['state'] = 0;
                 $this->conversation->update();
                 $data['text'] = 'Type your name:';
                 $data['reply_markup'] = Keyboard::remove(['selective' => true]);
                 $result = Request::sendMessage($data);
                 break;
             }
             $notes['name'] = $text;
             $text = '';
             // no break
         // no break
         case 1:
             if ($text === '') {
                 $notes['state'] = 1;
                 $this->conversation->update();
                 $data['text'] = 'Type your surname:';
                 $result = Request::sendMessage($data);
                 break;
             }
             $notes['surname'] = $text;
             $text = '';
             // no break
         // no break
         case 2:
             if ($text === '' || !is_numeric($text)) {
                 $notes['state'] = 2;
                 $this->conversation->update();
                 $data['text'] = 'Type your age:';
                 if ($text !== '') {
                     $data['text'] = 'Type your age, must be a number:';
                 }
                 $result = Request::sendMessage($data);
                 break;
             }
             $notes['age'] = $text;
             $text = '';
             // no break
         // no break
         case 3:
             if ($text === '' || !in_array($text, ['M', 'F'], true)) {
                 $notes['state'] = 3;
                 $this->conversation->update();
                 $data['reply_markup'] = (new Keyboard(['M', 'F']))->setResizeKeyboard(true)->setOneTimeKeyboard(true)->setSelective(true);
                 $data['text'] = 'Select your gender:';
                 if ($text !== '') {
                     $data['text'] = 'Select your gender, choose a keyboard option:';
                 }
                 $result = Request::sendMessage($data);
                 break;
             }
             $notes['gender'] = $text;
             // no break
         // no break
         case 4:
             if ($message->getLocation() === null) {
                 $notes['state'] = 4;
                 $this->conversation->update();
                 $data['reply_markup'] = (new Keyboard((new KeyboardButton('Share Location'))->setRequestLocation(true)))->setOneTimeKeyboard(true)->setResizeKeyboard(true)->setSelective(true);
                 $data['text'] = 'Share your location:';
                 $result = Request::sendMessage($data);
                 break;
             }
             $notes['longitude'] = $message->getLocation()->getLongitude();
//.........这里部分代码省略.........
开发者ID:akalongman,项目名称:php-telegram-bot,代码行数:101,代码来源:SurveyCommand.php

示例3: execute

 /**
  * A system command just executes
  *
  * Although system commands should just work and return a successful ServerResponse,
  * each system command can override this method to add custom functionality.
  *
  * @return Entities\ServerResponse
  */
 public function execute()
 {
     //System command, return empty ServerResponse
     return Request::emptyResponse();
 }
开发者ID:noplanman,项目名称:php-telegram-bot,代码行数:13,代码来源:SystemCommand.php


注:本文中的Longman\TelegramBot\Request::emptyResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。