From 69916fed3e64e1b7dea13a50887672f561d6439a Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 29 Nov 2024 22:06:07 -0500 Subject: [PATCH] Improve command check with method existence validation --- CHANGELOG.md | 1 + src/TgBotLib/Bot.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 972b754..cea1ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This update introduces bug fixes and improvements ### Fixed * Reposition debug log for event handler execution. + * Improve command check with method existence validation ## [8.0.0] - 2024-11-29 diff --git a/src/TgBotLib/Bot.php b/src/TgBotLib/Bot.php index 58a8e6f..a2a0e38 100644 --- a/src/TgBotLib/Bot.php +++ b/src/TgBotLib/Bot.php @@ -365,10 +365,11 @@ /** @var UpdateEvent $eventHandler */ foreach($this->eventHandlers as $eventHandler) { - if(strtolower($eventHandler::getCommand()) === strtolower($command)) + if(method_exists($eventHandler, 'getCommand') && strtolower($eventHandler::getCommand()) === strtolower($command)) { $results[] = $eventHandler; } + } return $results;