mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-09-21 05:12:34 +00:00
Support str type for aliases
This commit is contained in:
parent
cfa9fc3936
commit
f7e4223dc6
@ -151,7 +151,7 @@ class CommandFunc:
|
|||||||
|
|
||||||
|
|
||||||
def on_command(name: Union[str, CommandName_T], *,
|
def on_command(name: Union[str, CommandName_T], *,
|
||||||
aliases: Iterable[str] = (),
|
aliases: Union[Iterable[str], str] = (),
|
||||||
permission: int = perm.EVERYBODY,
|
permission: int = perm.EVERYBODY,
|
||||||
only_to_me: bool = True,
|
only_to_me: bool = True,
|
||||||
privileged: bool = False,
|
privileged: bool = False,
|
||||||
@ -189,6 +189,9 @@ def on_command(name: Union[str, CommandName_T], *,
|
|||||||
current_parent = current_parent[parent_key]
|
current_parent = current_parent[parent_key]
|
||||||
current_parent[cmd_name[-1]] = cmd
|
current_parent[cmd_name[-1]] = cmd
|
||||||
|
|
||||||
|
nonlocal aliases
|
||||||
|
if isinstance(aliases, str):
|
||||||
|
aliases = (aliases,)
|
||||||
for alias in aliases:
|
for alias in aliases:
|
||||||
_aliases[alias] = cmd_name
|
_aliases[alias] = cmd_name
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class CommandGroup:
|
|||||||
shell_like: bool = ...): ...
|
shell_like: bool = ...): ...
|
||||||
|
|
||||||
def command(self, name: Union[str, CommandName_T], *,
|
def command(self, name: Union[str, CommandName_T], *,
|
||||||
aliases: Iterable[str] = ...,
|
aliases: Union[Iterable[str], str] = ...,
|
||||||
permission: int = ...,
|
permission: int = ...,
|
||||||
only_to_me: bool = ...,
|
only_to_me: bool = ...,
|
||||||
privileged: bool = ...,
|
privileged: bool = ...,
|
||||||
|
Loading…
Reference in New Issue
Block a user