YaKotikTvoy

InlinekeyboardCommand

Jul 9th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * This file is part of the PHP Telegram Bot example-bot package.
  5.  * https://github.com/php-telegram-bot/example-bot/
  6.  *
  7.  * (c) PHP Telegram Bot Team
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12.  
  13. namespace Longman\TelegramBot\Commands\UserCommands;
  14.  
  15. /**
  16.  * User "/inlinekeyboard" command
  17.  *
  18.  * Display an inline keyboard with a few buttons.    
  19.  *
  20.  * This command requires CallbackqueryCommand to work!
  21.  *
  22.  * Отобразите встроенную клавиатуру с несколькими кнопками.
  23.  *
  24.  * Для работы этой команды требуется команда запроса обратного вызова!
  25.  * @see CallbackqueryCommand.php
  26.  */
  27.  
  28. use Longman\TelegramBot\Commands\UserCommand;
  29. use Longman\TelegramBot\Entities\InlineKeyboard;
  30. use Longman\TelegramBot\Entities\ServerResponse;
  31. use Longman\TelegramBot\Exception\TelegramException;
  32.  
  33. class InlinekeyboardCommand extends UserCommand
  34. {
  35.     /**
  36.      * @var string
  37.      */
  38.     protected $name = 'inlinekeyboard';
  39.  
  40.     /**
  41.      * @var string
  42.      */
  43.     protected $description = 'Show inline keyboard';
  44.  
  45.     /**
  46.      * @var string
  47.      */
  48.     protected $usage = '/inlinekeyboard';
  49.  
  50.     /**
  51.      * @var string
  52.      */
  53.     protected $version = '0.2.0';
  54.  
  55.     /**
  56.      * Main command execution
  57.      *
  58.      * @return ServerResponse
  59.      * @throws TelegramException
  60.      */
  61.     public function execute(): ServerResponse
  62.     {
  63.         $inline_keyboard = new InlineKeyboard([
  64.             ['text' => 'Callback', 'callback_data' => '1'],
  65.             ['text' => 'Callback', 'callback_data' => '1'],
  66.         ], [
  67.             ['text' => 'Callback', 'callback_data' => '1'],
  68.             ['text' => 'Callback', 'callback_data' => '1'],
  69.         ]);
  70.  
  71.         return $this->replyToChat('Вопрос 1', [
  72.             'reply_markup' => $inline_keyboard,
  73.         ]);
  74.     }
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment