You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.8 KiB

1 year ago
  1. <?php
  2. /**
  3. * This file is part of the PHP Telegram Bot example-bot package.
  4. * https://github.com/php-telegram-bot/example-bot/
  5. *
  6. * (c) PHP Telegram Bot Team
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Longman\TelegramBot\Commands\UserCommands;
  12. /**
  13. * User "/inlinekeyboard" command
  14. *
  15. * Display an inline keyboard with a few buttons.
  16. *
  17. * This command requires CallbackqueryCommand to work!
  18. *
  19. * @see CallbackqueryCommand.php
  20. */
  21. use Longman\TelegramBot\Commands\UserCommand;
  22. use Longman\TelegramBot\Entities\InlineKeyboard;
  23. use Longman\TelegramBot\Entities\ServerResponse;
  24. use Longman\TelegramBot\Exception\TelegramException;
  25. class InlinekeyboardCommand extends UserCommand
  26. {
  27. /**
  28. * @var string
  29. */
  30. protected $name = 'inlinekeyboard';
  31. /**
  32. * @var string
  33. */
  34. protected $description = 'Show inline keyboard';
  35. /**
  36. * @var string
  37. */
  38. protected $usage = '/inlinekeyboard';
  39. /**
  40. * @var string
  41. */
  42. protected $version = '0.2.0';
  43. /**
  44. * Main command execution
  45. *
  46. * @return ServerResponse
  47. * @throws TelegramException
  48. */
  49. public function execute(): ServerResponse
  50. {
  51. $inline_keyboard = new InlineKeyboard([
  52. ['text' => 'Inline Query (current chat)', 'switch_inline_query_current_chat' => 'inline query...'],
  53. ['text' => 'Inline Query (other chat)', 'switch_inline_query' => 'inline query...'],
  54. ], [
  55. ['text' => 'Callback', 'callback_data' => 'identifier'],
  56. ['text' => 'Open URL', 'url' => 'https://github.com/php-telegram-bot/example-bot'],
  57. ]);
  58. return $this->replyToChat('Inline Keyboard', [
  59. 'reply_markup' => $inline_keyboard,
  60. ]);
  61. }
  62. }