mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-27 16:21:28 +00:00
🎨 improve command implementation
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import re
|
||||
from typing import overload
|
||||
|
||||
from nonebot.typing import Rule, Matcher, Handler, Permission, RuleChecker, MatcherGroup
|
||||
from nonebot.typing import Rule, Matcher, Handler, Permission, RuleChecker
|
||||
from nonebot.typing import Set, List, Dict, Type, Tuple, Union, Optional, ModuleType
|
||||
|
||||
plugins: Dict[str, "Plugin"] = ...
|
||||
@ -92,10 +91,9 @@ def on_endswith(msg: str,
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def on_command(cmd: Union[str, Tuple[str, ...]],
|
||||
rule: Optional[Union[Rule, RuleChecker]] = ...,
|
||||
aliases: None = ...,
|
||||
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
|
||||
permission: Optional[Permission] = ...,
|
||||
*,
|
||||
handlers: Optional[List[Handler]] = ...,
|
||||
@ -106,20 +104,6 @@ def on_command(cmd: Union[str, Tuple[str, ...]],
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def on_command(cmd: Union[str, Tuple[str, ...]],
|
||||
rule: Optional[Union[Rule, RuleChecker]] = ...,
|
||||
aliases: Set[Union[str, Tuple[str, ...]]] = ...,
|
||||
permission: Optional[Permission] = ...,
|
||||
*,
|
||||
handlers: Optional[List[Handler]] = ...,
|
||||
temp: bool = ...,
|
||||
priority: int = ...,
|
||||
block: bool = ...,
|
||||
state: Optional[dict] = ...) -> MatcherGroup:
|
||||
...
|
||||
|
||||
|
||||
def on_regex(pattern: str,
|
||||
flags: Union[int, re.RegexFlag] = 0,
|
||||
rule: Optional[Rule] = ...,
|
||||
@ -163,16 +147,15 @@ class CommandGroup:
|
||||
state: Optional[dict] = ...):
|
||||
...
|
||||
|
||||
def command(
|
||||
self,
|
||||
cmd: Union[str, Tuple[str, ...]],
|
||||
rule: Optional[Union[Rule, RuleChecker]] = ...,
|
||||
aliases: Set[Union[str, Tuple[str, ...]]] = ...,
|
||||
permission: Optional[Permission] = ...,
|
||||
*,
|
||||
handlers: Optional[List[Handler]] = ...,
|
||||
temp: bool = ...,
|
||||
priority: int = ...,
|
||||
block: bool = ...,
|
||||
state: Optional[dict] = ...) -> Union[Type[Matcher], MatcherGroup]:
|
||||
def command(self,
|
||||
cmd: Union[str, Tuple[str, ...]],
|
||||
rule: Optional[Union[Rule, RuleChecker]] = ...,
|
||||
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
|
||||
permission: Optional[Permission] = ...,
|
||||
*,
|
||||
handlers: Optional[List[Handler]] = ...,
|
||||
temp: bool = ...,
|
||||
priority: int = ...,
|
||||
block: bool = ...,
|
||||
state: Optional[dict] = ...) -> Type[Matcher]:
|
||||
...
|
||||
|
Reference in New Issue
Block a user