Improve command handling in PollingBot

This commit is contained in:
netkas 2024-11-04 13:49:50 -05:00
parent 439ccdb123
commit f03490cb6c
4 changed files with 73 additions and 73 deletions

View file

@ -1008,20 +1008,24 @@
*/
public function getCommand(): ?string
{
if ($this->text === null)
if ($this->getAnyText() === null)
{
return null;
}
$text = trim($this->text);
$text = trim($this->getAnyText());
if (!str_starts_with($text, '/'))
{
return null;
}
$parts = explode(' ', $text);
return ltrim($parts[0], '/');
if (preg_match('/^\/([a-zA-Z0-9_]+)(?:@[a-zA-Z0-9_]+)?/', $text, $matches))
{
return $matches[1];
}
return null;
}
/**