diff --git a/src/Command/ButtonDeleteCommand.php b/src/Command/ButtonDeleteCommand.php index 0285500..e177b73 100644 --- a/src/Command/ButtonDeleteCommand.php +++ b/src/Command/ButtonDeleteCommand.php @@ -8,11 +8,16 @@ use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method; use Luzrain\TelegramBotApi\Type; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'telegram:button:delete', + description: 'Delete bot\'s menu button', +)] final class ButtonDeleteCommand extends Command { public function __construct( @@ -21,16 +26,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:button:delete'; - } - - public static function getDefaultDescription(): string - { - return 'Delete bot\'s mebu button'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/ButtonUpdateCommand.php b/src/Command/ButtonUpdateCommand.php index 83087f8..02f6390 100644 --- a/src/Command/ButtonUpdateCommand.php +++ b/src/Command/ButtonUpdateCommand.php @@ -9,11 +9,16 @@ use Luzrain\TelegramBotApi\Method; use Luzrain\TelegramBotApi\Type; use Luzrain\TelegramBotBundle\CommandMetadataProvider; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'telegram:button:update', + description: 'Set published list of commands as as default bot\'s menu button', +)] final class ButtonUpdateCommand extends Command { private \Closure $descriptionProcessor; @@ -27,16 +32,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:button:update'; - } - - public static function getDefaultDescription(): string - { - return 'Set published list of commands as as default bot\'s mebu button'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/PolllingStartCommand.php b/src/Command/PolllingStartCommand.php index a1c168a..adae7f5 100644 --- a/src/Command/PolllingStartCommand.php +++ b/src/Command/PolllingStartCommand.php @@ -8,12 +8,17 @@ use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotBundle\LongPollingService; use Luzrain\TelegramBotBundle\UpdateHandler; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'telegram:polling:start', + description: 'Run polling client to receive updates', +)] final class PolllingStartCommand extends Command { public function __construct( @@ -24,16 +29,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:polling:start'; - } - - public static function getDefaultDescription(): string - { - return 'Run polling client to receive updates'; - } - protected function configure(): void { $this->addOption('timeout', null, InputOption::VALUE_REQUIRED, 'Timeout for long polling connection in seconds', 15); diff --git a/src/Command/WebhookDeleteCommand.php b/src/Command/WebhookDeleteCommand.php index db09a99..5b2d28f 100644 --- a/src/Command/WebhookDeleteCommand.php +++ b/src/Command/WebhookDeleteCommand.php @@ -7,11 +7,16 @@ use Luzrain\TelegramBotApi\BotApi; use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'telegram:webhook:delete', + description: 'Remove webhook integration', +)] final class WebhookDeleteCommand extends Command { public function __construct( @@ -20,16 +25,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:webhook:delete'; - } - - public static function getDefaultDescription(): string - { - return 'Remove webhook integration'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/WebhookInfoCommand.php b/src/Command/WebhookInfoCommand.php index 695ad6f..1d0436c 100644 --- a/src/Command/WebhookInfoCommand.php +++ b/src/Command/WebhookInfoCommand.php @@ -7,11 +7,16 @@ use Luzrain\TelegramBotApi\BotApi; use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'telegram:webhook:info', + description: 'Get current webhook status', +)] final class WebhookInfoCommand extends Command { public function __construct( @@ -20,16 +25,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:webhook:info'; - } - - public static function getDefaultDescription(): string - { - return 'Get current webhook status'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/WebhookUpdateCommand.php b/src/Command/WebhookUpdateCommand.php index f1f74a2..e8fb960 100644 --- a/src/Command/WebhookUpdateCommand.php +++ b/src/Command/WebhookUpdateCommand.php @@ -8,12 +8,17 @@ use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method\SetWebhook; use Luzrain\TelegramBotApi\Type\InputFile; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'telegram:webhook:update', + description: 'Update webhook settings', +)] final class WebhookUpdateCommand extends Command { public function __construct( @@ -28,16 +33,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:webhook:update'; - } - - public static function getDefaultDescription(): string - { - return 'Update webhook settings'; - } - protected function configure(): void { $this->addOption('url', null, InputOption::VALUE_REQUIRED, 'Webhook url'); diff --git a/src/config/services.php b/src/config/services.php index 53a2b01..755b126 100644 --- a/src/config/services.php +++ b/src/config/services.php @@ -55,7 +55,7 @@ $container ->register('telegram_bot.webhook_update_command', WebhookUpdateCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([ new Reference(BotApi::class), $config['allowed_updates'], @@ -68,19 +68,19 @@ $container ->register('telegram_bot.webhook_info_command', WebhookInfoCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([new Reference(BotApi::class)]) ; $container ->register('telegram_bot.webhook_delete_command', WebhookDeleteCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([new Reference(BotApi::class)]) ; $container ->register('telegram_bot.polling_start_command', PolllingStartCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([ new Reference('telegram_bot.long_polling_service'), new Reference('telegram_bot.update_handler'), @@ -90,7 +90,7 @@ $container ->register('telegram_bot.button_update_commands', ButtonUpdateCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([ new Reference(BotApi::class), new Reference('telegram_bot.command_metadata_provider'), @@ -100,7 +100,7 @@ $container ->register('telegram_bot.button_delete_command', ButtonDeleteCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([new Reference(BotApi::class)]) ;