2020-08-23 17:03:59 +08:00
|
|
|
---
|
|
|
|
contentSidebar: true
|
|
|
|
sidebarDepth: 0
|
|
|
|
---
|
|
|
|
|
2020-08-19 20:29:37 +08:00
|
|
|
# NoneBot.typing 模块
|
|
|
|
|
|
|
|
## 类型
|
|
|
|
|
|
|
|
下面的文档中,「类型」部分使用 Python 的 Type Hint 语法,见 [PEP 484](https://www.python.org/dev/peps/pep-0484/)、[PEP 526](https://www.python.org/dev/peps/pep-0526/) 和 [typing](https://docs.python.org/3/library/typing.html)。
|
|
|
|
|
|
|
|
除了 Python 内置的类型,下面还出现了如下 NoneBot 自定类型,实际上它们是 Python 内置类型的别名。
|
|
|
|
|
|
|
|
以下类型均可从 nonebot.typing 模块导入。
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Driver`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
BaseDriver
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
所有 Driver 的基类。
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `WebSocket`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
BaseWebSocket
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
所有 WebSocket 的基类。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Bot`
|
2020-08-19 23:00:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
BaseBot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
所有 Bot 的基类。
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Event`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
BaseEvent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
所有 Event 的基类。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Message`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
BaseMessage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
所有 Message 的基类。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `MessageSegment`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
BaseMessageSegment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
所有 MessageSegment 的基类。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `PreProcessor`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
消息预处理函数 PreProcessor 类型
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Matcher`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
Matcher
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
Matcher 即响应事件的处理类。通过 Rule 判断是否响应事件,运行 Handler。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Rule`
|
2020-08-19 20:29:37 +08:00
|
|
|
|
|
|
|
|
2020-08-19 23:00:31 +08:00
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Rule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
Rule 即判断是否响应事件的处理类。内部存储 RuleChecker ,返回全为 True 则响应事件。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `RuleChecker`
|
2020-08-19 23:00:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Callable[[Bot, Event, dict], Awaitable[bool]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
RuleChecker 即判断是否响应事件的处理函数。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Permission`
|
2020-08-19 23:00:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Permission
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
Permission 即判断是否响应消息的处理类。内部存储 PermissionChecker ,返回只要有一个 True 则响应消息。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `PermissionChecker`
|
2020-08-19 23:00:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Callable[[Bot, Event], Awaitable[bool]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
RuleChecker 即判断是否响应消息的处理函数。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `Handler`
|
2020-08-19 23:00:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
Handler 即事件的处理函数。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-20 15:07:05 +08:00
|
|
|
## `ArgsParser`
|
2020-08-19 23:00:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
* **类型**
|
|
|
|
|
|
|
|
Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* **说明**
|
|
|
|
|
|
|
|
ArgsParser 即消息参数解析函数,在 Matcher.got 获取参数时被运行。
|