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.

60 lines
1.3 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. use Longman\TelegramBot\Commands\UserCommand;
  13. use Longman\TelegramBot\Entities\Keyboard;
  14. use Longman\TelegramBot\Entities\ServerResponse;
  15. use Longman\TelegramBot\Exception\TelegramException;
  16. /**
  17. * User "/forcereply" command
  18. *
  19. * Force a reply to a message.
  20. */
  21. class ForcereplyCommand extends UserCommand
  22. {
  23. /**
  24. * @var string
  25. */
  26. protected $name = 'forcereply';
  27. /**
  28. * @var string
  29. */
  30. protected $description = 'Force reply with reply markup';
  31. /**
  32. * @var string
  33. */
  34. protected $usage = '/forcereply';
  35. /**
  36. * @var string
  37. */
  38. protected $version = '0.2.0';
  39. /**
  40. * Main command execution
  41. *
  42. * @return ServerResponse
  43. * @throws TelegramException
  44. */
  45. public function execute(): ServerResponse
  46. {
  47. // Force a reply to the sent message
  48. return $this->replyToChat('Write something in reply:', [
  49. 'reply_markup' => Keyboard::forceReply(),
  50. ]);
  51. }
  52. }