This commit is contained in:
2025-03-06 01:35:18 +03:00
parent a57ce490c1
commit b61c151e1c
5 changed files with 21 additions and 5 deletions
+4 -1
View File
@@ -8,7 +8,8 @@ from ..router.exceptions import (RepeatedCommandException,
RepeatedFlagNameException,
TooManyTransferredArgsException,
RequiredArgumentNotPassedException,
IncorrectNumberOfHandlerArgsException)
IncorrectNumberOfHandlerArgsException,
TriggerCannotContainSpacesException)
class Router:
@@ -71,6 +72,8 @@ class Router:
def _validate_command(self, command: Command):
command_name: str = command.get_trigger()
if command_name.find(' ') != -1:
raise TriggerCannotContainSpacesException()
if command_name in self.get_all_commands():
raise RepeatedCommandException()
if self._ignore_command_register:
+5
View File
@@ -21,3 +21,8 @@ class RequiredArgumentNotPassedException(Exception):
class IncorrectNumberOfHandlerArgsException(Exception):
def __str__(self):
return "Handler has incorrect number of arguments"
class TriggerCannotContainSpacesException(Exception):
def __str__(self):
return "Command trigger cannot contain spaces"