diff --git a/src/TgBotLib/Events/CommandEvent.php b/src/TgBotLib/Events/CommandEvent.php new file mode 100644 index 0000000..f5ce420 --- /dev/null +++ b/src/TgBotLib/Events/CommandEvent.php @@ -0,0 +1,64 @@ +update->getMessage(); + } + + /** + * Extracts and returns the arguments of the command from the message text. + * + * @return string The arguments of the command. + */ + protected function getArguments(): string + { + if(strlen($this->getMessage()->getText()) <= strlen(static::getCommand()) + 1) + { + return ''; + } + + return substr($this->getMessage()->getText(), strlen(static::getCommand()) + 1); + } + + /** + * Parses and returns the command arguments as an array. + * + * @return array The parsed command arguments. + */ + protected function getParsedArguments(): array + { + return Parse::parseArgument($this->getArguments()); + } + } \ No newline at end of file