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.

74 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. /**
  12. * Generic message command
  13. *
  14. * Gets executed when any type of message is sent.
  15. *
  16. * In this service-message-related context, we can handle any incoming service-messages.
  17. */
  18. namespace Longman\TelegramBot\Commands\SystemCommands;
  19. use Longman\TelegramBot\Commands\SystemCommand;
  20. use Longman\TelegramBot\Entities\ServerResponse;
  21. use Longman\TelegramBot\Request;
  22. class GenericmessageCommand extends SystemCommand
  23. {
  24. /**
  25. * @var string
  26. */
  27. protected $name = 'genericmessage';
  28. /**
  29. * @var string
  30. */
  31. protected $description = 'Handle generic message';
  32. /**
  33. * @var string
  34. */
  35. protected $version = '1.0.0';
  36. /**
  37. * Main command execution
  38. *
  39. * @return ServerResponse
  40. */
  41. public function execute(): ServerResponse
  42. {
  43. $message = $this->getMessage();
  44. /**
  45. * Catch and handle any service messages here.
  46. */
  47. // The chat photo was deleted
  48. $delete_chat_photo = $message->getDeleteChatPhoto();
  49. // The group has been created
  50. $group_chat_created = $message->getGroupChatCreated();
  51. // The supergroup has been created
  52. $supergroup_chat_created = $message->getSupergroupChatCreated();
  53. // The channel has been created
  54. $channel_chat_created = $message->getChannelChatCreated();
  55. // Information about the payment
  56. $successful_payment = $message->getSuccessfulPayment();
  57. return Request::emptyResponse();
  58. }
  59. }