diff --git a/src/Commands/BotCommand.php b/src/Commands/BotCommand.php index e903b9f..5941b93 100644 --- a/src/Commands/BotCommand.php +++ b/src/Commands/BotCommand.php @@ -34,7 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } - protected function configureBotArguments() + protected function configure() { $this->addOption('bot-token', 't', InputOption::VALUE_REQUIRED, 'Telegram Bot API Token'); $defaultApiUrl = TelegramBot::DEFAULT_API_SERVER_URL; diff --git a/src/Commands/Close.php b/src/Commands/Close.php index 7a1c0fc..7a19bd0 100644 --- a/src/Commands/Close.php +++ b/src/Commands/Close.php @@ -8,15 +8,11 @@ use Telepath\Exceptions\TelegramException; #[AsCommand( - name: 'close', + name: 'server:close', description: 'Close the bot instance before moving it from one local server to another.' )] class Close extends BotCommand { - protected function configure() - { - $this->configureBotArguments(); - } protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Commands/DeleteWebhook.php b/src/Commands/DeleteWebhook.php index c049500..5553b90 100644 --- a/src/Commands/DeleteWebhook.php +++ b/src/Commands/DeleteWebhook.php @@ -16,7 +16,7 @@ class DeleteWebhook extends BotCommand protected function configure() { - $this->configureBotArguments(); + parent::configure(); $this->addOption('drop-pending-updates', 'd', InputOption::VALUE_NONE, 'Drop all pending updates'); } diff --git a/src/Commands/GetMe.php b/src/Commands/GetMe.php new file mode 100644 index 0000000..6e6f70d --- /dev/null +++ b/src/Commands/GetMe.php @@ -0,0 +1,59 @@ +makeBot($input, $output); + + $user = $bot->getMe(); + + $table = new Table($output); + $table->setHeaderTitle('User'); + + $table->setHeaders([ + 'id', + 'is_bot', + 'first_name', + 'last_name', + 'username', + 'can_join_groups', + 'can_read_all_group_messages', + 'supports_inline_queries', + ]); + + $table->setRow(0, [ + $user->id, + $user->is_bot ? 'true' : 'false', + $user->first_name, + $user->last_name, + $user->username, + $user->can_join_groups ? 'true' : 'false', + $user->can_read_all_group_messages ? 'true' : 'false', + $user->supports_inline_queries ? 'true' : 'false', + ]); + + $table->setVertical(); + $table->setStyle('box'); + + $table->render(); + + return self::SUCCESS; + } + + +} \ No newline at end of file diff --git a/src/Commands/GetWebhookInfo.php b/src/Commands/GetWebhookInfo.php index 121d512..c651838 100644 --- a/src/Commands/GetWebhookInfo.php +++ b/src/Commands/GetWebhookInfo.php @@ -13,10 +13,6 @@ )] class GetWebhookInfo extends BotCommand { - protected function configure() - { - $this->configureBotArguments(); - } protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Commands/LogOut.php b/src/Commands/LogOut.php index 9c262dd..ee78267 100644 --- a/src/Commands/LogOut.php +++ b/src/Commands/LogOut.php @@ -8,17 +8,12 @@ use Telepath\Exceptions\TelegramException; #[AsCommand( - name: 'logout', + name: 'server:logout', description: 'Log out from the cloud Bot API server before launching the bot locally.' )] class LogOut extends BotCommand { - protected function configure() - { - $this->configureBotArguments(); - } - protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); diff --git a/src/Commands/SetWebhook.php b/src/Commands/SetWebhook.php index 620d432..5417558 100644 --- a/src/Commands/SetWebhook.php +++ b/src/Commands/SetWebhook.php @@ -21,7 +21,7 @@ class SetWebhook extends BotCommand protected function configure() { - $this->configureBotArguments(); + parent::configure(); $this->addArgument('url', InputArgument::OPTIONAL, 'HTTPS URL to send updates to'); diff --git a/telepathy b/telepathy index 6441d93..39eccd4 100755 --- a/telepathy +++ b/telepathy @@ -12,6 +12,7 @@ foreach ([__DIR__ . '/../../autoload.php', __DIR__ . '/../autoload.php', __DIR__ use Symfony\Component\Console\Application; use Telepath\Commands\Close; use Telepath\Commands\DeleteWebhook; +use Telepath\Commands\GetMe; use Telepath\Commands\GetWebhookInfo; use Telepath\Commands\LogOut; use Telepath\Commands\SetWebhook; @@ -26,6 +27,7 @@ $application->addCommands([ new GetWebhookInfo(), new LogOut(), new Close(), + new GetMe(), ]); $application->run(); \ No newline at end of file