Improve command handling in PollingBot

This commit is contained in:
netkas 2024-11-04 01:22:30 -05:00
parent a4af8fd1b7
commit 439ccdb123

View file

@ -235,15 +235,20 @@
{ {
// Check if the update contains a command // Check if the update contains a command
$command = $update?->getAnyMessage()?->getCommand(); $command = $update?->getAnyMessage()?->getCommand();
$commandExecuted = false;
if ($command !== null) if ($command !== null)
{ {
foreach ($this->getEventHandlersByCommand($command) as $commandHandler) foreach ($this->getEventHandlersByCommand($command) as $commandHandler)
{ {
(new $commandHandler($update))->handle($this); (new $commandHandler($update))->handle($this);
$commandExecuted = true;
} }
if($commandExecuted)
{
continue; continue;
} }
}
// Check if the update contains a callback query // Check if the update contains a callback query
$updateByType = $this->getEventHandlersByType(EventType::determineEventType($update)); $updateByType = $this->getEventHandlersByType(EventType::determineEventType($update));