diff --git a/maubot/handlers/command.py b/maubot/handlers/command.py index 0f1e0cd..800dd52 100644 --- a/maubot/handlers/command.py +++ b/maubot/handlers/command.py @@ -89,7 +89,7 @@ class CommandHandler: if not evt.content.body or evt.content.body[0] != "!": return command, remaining_val = _split_in_two(evt.content.body[1:], " ") - if not self.__mb_is_command_match__(self, command): + if not self.__mb_is_command_match__(self.__bound_instance__, command): return call_args: Dict[str, Any] = {**_existing_args} if _existing_args else {} @@ -117,7 +117,7 @@ class CommandHandler: remaining_val: str) -> Tuple[bool, Any]: command, remaining_val = _split_in_two(remaining_val.strip(), " ") for subcommand in self.__mb_subcommands__: - if subcommand.__mb_is_command_match__(subcommand, command): + if subcommand.__mb_is_command_match__(subcommand.__bound_instance__, command): return True, await subcommand(evt, _existing_args=call_args, remaining_val=remaining_val) return False, None @@ -229,10 +229,10 @@ def new(name: PrefixType = None, *, help: str = None, aliases: AliasesType = Non else: func.__mb_is_command_match__ = aliases elif isinstance(aliases, (list, set, tuple)): - func.__mb_is_command_match__ = lambda self, val: (val == self.__mb_name__ + func.__mb_is_command_match__ = lambda self, val: (val == func.__mb_name__ or val in aliases) else: - func.__mb_is_command_match__ = lambda self, val: val == self.__mb_name__ + func.__mb_is_command_match__ = lambda self, val: val == func.__mb_name__ # Decorators are executed last to first, so we reverse the argument list. func.__mb_arguments__.reverse() func.__mb_require_subcommand__ = require_subcommand