diff --git a/src/Hello/Telegram/Command/HelloCommand.php b/src/Hello/Telegram/Command/HelloCommand.php index 7fd6183..6f00d75 100644 --- a/src/Hello/Telegram/Command/HelloCommand.php +++ b/src/Hello/Telegram/Command/HelloCommand.php @@ -11,6 +11,7 @@ namespace App\Hello\Telegram\Command; +use Psr\Log\LoggerInterface; use BoShurik\TelegramBotBundle\Telegram\Command\AbstractCommand; use BoShurik\TelegramBotBundle\Telegram\Command\PublicCommandInterface; use TelegramBot\Api\BotApi; @@ -18,6 +19,13 @@ class HelloCommand extends AbstractCommand implements PublicCommandInterface { + private $logger; + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + public function getName(): string { return '/hello'; @@ -30,6 +38,7 @@ public function getDescription(): string public function execute(BotApi $api, Update $update): void { + $this->logger->info('Executing HelloCommand'); preg_match(self::REGEXP, $update->getMessage()->getText(), $matches); $who = !empty($matches[3]) ? $matches[3] : 'World'; diff --git a/src/Help/Telegram/Command/HelpCommand.php b/src/Help/Telegram/Command/HelpCommand.php index d811553..6388e59 100644 --- a/src/Help/Telegram/Command/HelpCommand.php +++ b/src/Help/Telegram/Command/HelpCommand.php @@ -11,13 +11,22 @@ namespace App\Help\Telegram\Command; +use Psr\Log\LoggerInterface; use BoShurik\TelegramBotBundle\Telegram\Command\HelpCommand as BaseCommand; use TelegramBot\Api\Types\Update; class HelpCommand extends BaseCommand { + private $logger; + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + public function isApplicable(Update $update): bool { + $this->logger->info('Checking applicability of HelpCommand'); return $update->getMessage() !== null; } }