Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/Command/ButtonDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
15 changes: 5 additions & 10 deletions src/Command/ButtonUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
15 changes: 5 additions & 10 deletions src/Command/PolllingStartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
15 changes: 5 additions & 10 deletions src/Command/WebhookDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
15 changes: 5 additions & 10 deletions src/Command/WebhookInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
15 changes: 5 additions & 10 deletions src/Command/WebhookUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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');
Expand Down
12 changes: 6 additions & 6 deletions src/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'),
Expand All @@ -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'),
Expand All @@ -100,7 +100,7 @@

$container
->register('telegram_bot.button_delete_command', ButtonDeleteCommand::class)
->addTag('console.command')
->setAutoconfigured(true)
->setArguments([new Reference(BotApi::class)])
;

Expand Down