2020-09-28 00:09:12 +08:00
|
|
|
import re
|
2021-11-08 01:02:35 +08:00
|
|
|
from typing import Set, List, Type, Tuple, Union, Optional
|
2020-09-28 00:09:12 +08:00
|
|
|
|
2021-09-18 16:11:03 +08:00
|
|
|
from nonebot.matcher import Matcher
|
2020-12-06 02:30:19 +08:00
|
|
|
from nonebot.permission import Permission
|
2021-12-12 18:19:08 +08:00
|
|
|
from nonebot.dependencies import Dependent
|
2021-02-02 11:59:14 +08:00
|
|
|
from nonebot.rule import Rule, ArgumentParser
|
2022-01-28 14:04:57 +08:00
|
|
|
from nonebot.typing import T_State, T_Handler, T_RuleChecker, T_PermissionChecker
|
2020-09-28 00:09:12 +08:00
|
|
|
|
2021-11-22 23:21:26 +08:00
|
|
|
def on(
|
|
|
|
type: str = "",
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_metaevent(
|
2021-11-22 23:21:26 +08:00
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_message(
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_notice(
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_request(
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_startswith(
|
|
|
|
msg: Union[str, Tuple[str, ...]],
|
2022-04-01 16:29:44 +08:00
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
ignorecase: bool = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_endswith(
|
|
|
|
msg: Union[str, Tuple[str, ...]],
|
2022-04-01 16:29:44 +08:00
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
ignorecase: bool = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2022-02-15 08:20:29 +08:00
|
|
|
def on_fullmatch(
|
|
|
|
msg: Union[str, Tuple[str, ...]],
|
2022-04-01 16:29:44 +08:00
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2022-02-15 08:20:29 +08:00
|
|
|
ignorecase: bool = ...,
|
|
|
|
*,
|
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2021-11-22 23:21:26 +08:00
|
|
|
def on_keyword(
|
|
|
|
keywords: Set[str],
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_command(
|
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_shell_command(
|
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
|
|
|
|
parser: Optional[ArgumentParser] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_regex(
|
|
|
|
pattern: str,
|
|
|
|
flags: Union[int, re.RegexFlag] = ...,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
*,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
|
|
|
|
class CommandGroup:
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
2020-12-20 11:59:23 +08:00
|
|
|
*,
|
2021-11-22 23:21:26 +08:00
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2020-12-20 11:59:23 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
): ...
|
|
|
|
def command(
|
|
|
|
self,
|
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
2020-12-20 11:59:23 +08:00
|
|
|
*,
|
2021-11-22 23:21:26 +08:00
|
|
|
aliases: Optional[Set[Union[str, Tuple[str, ...]]]],
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2020-12-20 11:59:23 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def shell_command(
|
|
|
|
self,
|
2021-04-04 12:19:03 +08:00
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
2021-11-22 23:21:26 +08:00
|
|
|
*,
|
2021-04-04 12:19:03 +08:00
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
aliases: Optional[Set[Union[str, Tuple[str, ...]]]],
|
2021-04-04 12:19:03 +08:00
|
|
|
parser: Optional[ArgumentParser] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-04-04 12:19:03 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
) -> Type[Matcher]: ...
|
2020-12-04 01:41:23 +08:00
|
|
|
|
|
|
|
class MatcherGroup:
|
2021-11-22 23:21:26 +08:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
*,
|
|
|
|
type: str = ...,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
): ...
|
|
|
|
def on(
|
|
|
|
self,
|
|
|
|
*,
|
|
|
|
type: str = ...,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_metaevent(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_message(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_notice(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_request(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_startswith(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
msg: Union[str, Tuple[str, ...]],
|
|
|
|
*,
|
|
|
|
ignorecase: bool = ...,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_endswith(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
msg: Union[str, Tuple[str, ...]],
|
|
|
|
*,
|
|
|
|
ignorecase: bool = ...,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
2022-02-15 08:20:29 +08:00
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
|
|
|
def on_fullmatch(
|
|
|
|
self,
|
|
|
|
msg: Union[str, Tuple[str, ...]],
|
|
|
|
*,
|
|
|
|
ignorecase: bool = ...,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_keyword(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
keywords: Set[str],
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_command(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
|
|
|
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2021-02-02 11:59:14 +08:00
|
|
|
def on_shell_command(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
cmd: Union[str, Tuple[str, ...]],
|
|
|
|
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
|
|
|
|
parser: Optional[ArgumentParser] = ...,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|
2020-12-20 11:59:23 +08:00
|
|
|
def on_regex(
|
2021-11-22 23:21:26 +08:00
|
|
|
self,
|
|
|
|
pattern: str,
|
|
|
|
flags: Union[int, re.RegexFlag] = ...,
|
|
|
|
*,
|
|
|
|
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
|
2021-12-12 18:19:08 +08:00
|
|
|
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
|
|
|
|
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
|
2021-11-22 23:21:26 +08:00
|
|
|
temp: bool = ...,
|
|
|
|
priority: int = ...,
|
|
|
|
block: bool = ...,
|
|
|
|
state: Optional[T_State] = ...,
|
|
|
|
) -> Type[Matcher]: ...
|