nonebot2/nonebot/plugin.pyi

336 lines
11 KiB
Python
Raw Normal View History

2020-09-28 00:09:12 +08:00
import re
2020-12-06 02:30:19 +08:00
from types import ModuleType
2020-11-21 20:40:09 +08:00
from contextvars import ContextVar
2020-12-06 02:30:19 +08:00
from typing import Any, Set, List, Dict, Type, Tuple, Union, Optional
2020-09-28 00:09:12 +08:00
2020-12-06 02:30:19 +08:00
from nonebot.rule import Rule
from nonebot.matcher import Matcher
from nonebot.permission import Permission
from nonebot.typing import State, Handler, RuleChecker
2020-09-28 00:09:12 +08:00
plugins: Dict[str, "Plugin"] = ...
2020-11-21 20:40:09 +08:00
_tmp_matchers: ContextVar[Set[Type[Matcher]]] = ...
_export: ContextVar["Export"] = ...
class Export(dict):
def __call__(self, func, **kwargs):
...
def __setattr__(self, name, value):
...
def __getattr__(self, name):
...
2020-09-28 00:09:12 +08:00
class Plugin(object):
name: str
module: ModuleType
matcher: Set[Type[Matcher]]
2020-11-21 20:40:09 +08:00
export: Export
2020-09-28 00:09:12 +08:00
2020-10-16 15:12:15 +08:00
def on(type: str = ...,
rule: Optional[Union[Rule, RuleChecker]] = ...,
2020-09-28 12:45:55 +08:00
permission: Optional[Permission] = ...,
2020-09-28 00:09:12 +08:00
*,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
2020-09-28 12:45:55 +08:00
def on_metaevent(rule: Optional[Union[Rule, RuleChecker]] = ...,
2020-09-28 00:09:12 +08:00
*,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
2020-09-28 12:45:55 +08:00
def on_message(rule: Optional[Union[Rule, RuleChecker]] = ...,
permission: Optional[Permission] = ...,
2020-09-28 00:09:12 +08:00
*,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
2020-09-28 12:45:55 +08:00
def on_notice(rule: Optional[Union[Rule, RuleChecker]] = ...,
2020-09-28 00:09:12 +08:00
*,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
2020-09-28 12:45:55 +08:00
def on_request(rule: Optional[Union[Rule, RuleChecker]] = ...,
2020-09-28 00:09:12 +08:00
*,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
def on_startswith(msg: str,
2020-09-28 12:45:55 +08:00
rule: Optional[Optional[Union[Rule, RuleChecker]]] = ...,
2020-09-28 00:09:12 +08:00
*,
permission: Optional[Permission] = ...,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
def on_endswith(msg: str,
2020-09-28 12:45:55 +08:00
rule: Optional[Optional[Union[Rule, RuleChecker]]] = ...,
2020-09-28 00:09:12 +08:00
*,
permission: Optional[Permission] = ...,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
def on_keyword(keywords: Set[str],
rule: Optional[Optional[Union[Rule, RuleChecker]]] = ...,
*,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...
2020-09-28 12:45:55 +08:00
def on_command(cmd: Union[str, Tuple[str, ...]],
rule: Optional[Union[Rule, RuleChecker]] = ...,
2020-10-22 22:08:19 +08:00
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = ...,
2020-09-28 12:45:55 +08:00
*,
permission: Optional[Permission] = ...,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 12:45:55 +08:00
...
2020-09-28 00:09:12 +08:00
def on_regex(pattern: str,
flags: Union[int, re.RegexFlag] = 0,
2020-09-28 12:45:55 +08:00
rule: Optional[Rule] = ...,
2020-09-28 00:09:12 +08:00
*,
permission: Optional[Permission] = ...,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
def load_plugin(module_path: str) -> Optional[Plugin]:
...
def load_plugins(*plugin_dir: str) -> Set[Plugin]:
...
def load_builtin_plugins():
...
2020-11-21 18:33:35 +08:00
def get_plugin(name: str) -> Optional[Plugin]:
...
2020-09-28 00:09:12 +08:00
def get_loaded_plugins() -> Set[Plugin]:
...
2020-11-21 20:40:09 +08:00
def export() -> Export:
...
def require(name: str) -> Export:
...
2020-09-28 00:09:12 +08:00
class CommandGroup:
def __init__(self,
cmd: Union[str, Tuple[str, ...]],
2020-09-28 12:45:55 +08:00
rule: Optional[Union[Rule, RuleChecker]] = ...,
permission: Optional[Permission] = ...,
2020-09-28 00:09:12 +08:00
*,
2020-09-28 12:45:55 +08:00
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...):
self.basecmd: Tuple[str, ...] = ...
self.base_kwargs: Dict[str, Any] = ...
2020-09-28 00:09:12 +08:00
2020-10-22 22:08:19 +08:00
def command(self,
cmd: Union[str, Tuple[str, ...]],
*,
2020-10-22 22:08:19 +08:00
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 = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
2020-09-28 00:09:12 +08:00
...
class MatcherGroup:
def __init__(self,
*,
type: str = ...,
rule: Optional[Union[Rule, RuleChecker]] = ...,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...):
...
def on(self,
*,
type: str = ...,
rule: Optional[Union[Rule, RuleChecker]] = ...,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...
def on_metaevent(self,
*,
rule: Optional[Union[Rule, RuleChecker]] = None,
handlers: Optional[List[Handler]] = None,
temp: bool = False,
priority: int = 1,
block: bool = False,
2020-12-06 02:30:19 +08:00
state: Optional[State] = None) -> Type[Matcher]:
...
def on_message(self,
*,
rule: Optional[Union[Rule, RuleChecker]] = None,
permission: Optional[Permission] = None,
handlers: Optional[List[Handler]] = None,
temp: bool = False,
priority: int = 1,
block: bool = True,
2020-12-06 02:30:19 +08:00
state: Optional[State] = None) -> Type[Matcher]:
...
def on_notice(self,
*,
rule: Optional[Union[Rule, RuleChecker]] = None,
handlers: Optional[List[Handler]] = None,
temp: bool = False,
priority: int = 1,
block: bool = False,
2020-12-06 02:30:19 +08:00
state: Optional[State] = None) -> Type[Matcher]:
...
def on_request(self,
*,
rule: Optional[Union[Rule, RuleChecker]] = None,
handlers: Optional[List[Handler]] = None,
temp: bool = False,
priority: int = 1,
block: bool = False,
2020-12-06 02:30:19 +08:00
state: Optional[State] = None) -> Type[Matcher]:
...
def on_startswith(self,
*,
msg: str,
rule: Optional[Optional[Union[Rule, RuleChecker]]] = ...,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...
def on_endswith(self,
*,
msg: str,
rule: Optional[Optional[Union[Rule, RuleChecker]]] = ...,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...
def on_keyword(self,
*,
keywords: Set[str],
rule: Optional[Optional[Union[Rule, RuleChecker]]] = ...,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...
def on_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 = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...
def on_regex(self,
*,
pattern: str,
flags: Union[int, re.RegexFlag] = 0,
rule: Optional[Rule] = ...,
permission: Optional[Permission] = ...,
handlers: Optional[List[Handler]] = ...,
temp: bool = ...,
priority: int = ...,
block: bool = ...,
2020-12-06 02:30:19 +08:00
state: Optional[State] = ...) -> Type[Matcher]:
...