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.5 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. /**
  12. * Start command
  13. *
  14. * Gets executed when a user first starts using the bot.
  15. *
  16. * When using deep-linking, the parameter can be accessed by getting the command text.
  17. *
  18. * @see https://core.telegram.org/bots#deep-linking
  19. */
  20. namespace Longman\TelegramBot\Commands\SystemCommands;
  21. use Longman\TelegramBot\Commands\SystemCommand;
  22. use Longman\TelegramBot\Entities\ServerResponse;
  23. use Longman\TelegramBot\Exception\TelegramException;
  24. class StartCommand extends SystemCommand
  25. {
  26. /**
  27. * @var string
  28. */
  29. protected $name = 'start';
  30. /**
  31. * @var string
  32. */
  33. protected $description = 'Start command';
  34. /**
  35. * @var string
  36. */
  37. protected $usage = '/start';
  38. /**
  39. * @var string
  40. */
  41. protected $version = '1.2.0';
  42. /**
  43. * @var bool
  44. */
  45. protected $private_only = true;
  46. /**
  47. * Main command execution
  48. *
  49. * @return ServerResponse
  50. * @throws TelegramException
  51. */
  52. public function execute(): ServerResponse
  53. {
  54. // If you use deep-linking, get the parameter like this:
  55. // $deep_linking_parameter = $this->getMessage()->getText(true);
  56. return $this->replyToChat(
  57. 'Hi there!' . PHP_EOL .
  58. 'Type /help to see all commands!'
  59. );
  60. }
  61. }