private function getCommand($data)
{
if (empty($data['text'])) {
return null;
}
$find = '/^' . preg_quote('<@' . $this->context['self']['id'] . '>', '/') . '[ ]*/';
$text = preg_replace($find, '', $data['text']);
if (empty($text)) {
return null;
}
foreach ($this->commands as $commandName => $availableCommand) {
$find = '/^' . preg_quote($commandName) . '/';
if (preg_match($find, $text)) {
return $availableCommand;
}
}
return null;
}