Fix __mb_is_command_match__
This commit is contained in:
parent
c01cf127be
commit
2bf1c41b53
@ -14,7 +14,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
from typing import (Union, Callable, Sequence, Pattern, Awaitable, NewType, Optional, Any, List,
|
from typing import (Union, Callable, Sequence, Pattern, Awaitable, NewType, Optional, Any, List,
|
||||||
Dict, Tuple, Set, Type)
|
Dict, Tuple, Set)
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import asyncio
|
import asyncio
|
||||||
import functools
|
import functools
|
||||||
@ -117,7 +117,7 @@ class CommandHandler:
|
|||||||
remaining_val: str) -> Tuple[bool, Any]:
|
remaining_val: str) -> Tuple[bool, Any]:
|
||||||
command, remaining_val = _split_in_two(remaining_val.strip(), " ")
|
command, remaining_val = _split_in_two(remaining_val.strip(), " ")
|
||||||
for subcommand in self.__mb_subcommands__:
|
for subcommand in self.__mb_subcommands__:
|
||||||
if subcommand.__mb_is_command_match__(subcommand.__bound_instance__, command):
|
if subcommand.__mb_is_command_match__(subcommand, command):
|
||||||
return True, await subcommand(evt, _existing_args=call_args,
|
return True, await subcommand(evt, _existing_args=call_args,
|
||||||
remaining_val=remaining_val)
|
remaining_val=remaining_val)
|
||||||
return False, None
|
return False, None
|
||||||
@ -228,10 +228,10 @@ def new(name: PrefixType = None, *, help: str = None, aliases: AliasesType = Non
|
|||||||
else:
|
else:
|
||||||
func.__mb_is_command_match__ = aliases
|
func.__mb_is_command_match__ = aliases
|
||||||
elif isinstance(aliases, (list, set, tuple)):
|
elif isinstance(aliases, (list, set, tuple)):
|
||||||
func.__mb_is_command_match__ = lambda self, val: (val == func.__mb_name__
|
func.__mb_is_command_match__ = lambda self, val: (val == self.__mb_name__
|
||||||
or val in aliases)
|
or val in aliases)
|
||||||
else:
|
else:
|
||||||
func.__mb_is_command_match__ = lambda self, val: val == func.__mb_name__
|
func.__mb_is_command_match__ = lambda self, val: val == self.__mb_name__
|
||||||
# Decorators are executed last to first, so we reverse the argument list.
|
# Decorators are executed last to first, so we reverse the argument list.
|
||||||
func.__mb_arguments__.reverse()
|
func.__mb_arguments__.reverse()
|
||||||
func.__mb_require_subcommand__ = require_subcommand
|
func.__mb_require_subcommand__ = require_subcommand
|
||||||
|
Loading…
Reference in New Issue
Block a user