📝 Update changelog
Some checks failed
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 3s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 3s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 3s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 3s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.9) (push) Failing after 3s
Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 3s
Ruff Lint / Ruff Lint (push) Failing after 3s
Site Deploy / publish (push) Failing after 3s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 1m34s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.9) (push) Failing after 3m3s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 3m31s
Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 3m59s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.9) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.11) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.12) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.10) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.11) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.12) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.9) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.10) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.11) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.12) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.9) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.10) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.11) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.12) (push) Has been cancelled
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.9) (push) Has been cancelled

This commit is contained in:
noneflow[bot]
2025-08-25 15:02:13 +00:00
parent e2463e9e39
commit 9e9c1a27e5
90 changed files with 1 additions and 2157 deletions

View File

@ -289,7 +289,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
`Arparma` 有如下属性: `Arparma` 有如下属性:
- 调试类 - 调试类
- matched: 是否匹配成功 - matched: 是否匹配成功
- error_data: 解析失败时剩余的数据 - error_data: 解析失败时剩余的数据
- error_info: 解析失败时的异常内容 - error_info: 解析失败时的异常内容

View File

@ -155,7 +155,6 @@ async def test_example(app: App):
1. `should_call_send` 1. `should_call_send`
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数: 定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
- `event`:回复的目标事件。 - `event`:回复的目标事件。
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。 - `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
- `result`send 的返回值,将会返回给插件。 - `result`send 的返回值,将会返回给插件。
@ -164,7 +163,6 @@ async def test_example(app: App):
2. `should_call_api` 2. `should_call_api`
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数: 定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
- `api`API 名称。 - `api`API 名称。
- `data`:预期的请求数据。 - `data`:预期的请求数据。
- `result`call_api 的返回值,将会返回给插件。 - `result`call_api 的返回值,将会返回给插件。

View File

@ -9,6 +9,7 @@ toc_max_heading_level: 2
### 📝 文档 ### 📝 文档
- Docs: 升级 docusaurus 3.8.1 [@StarHeartHunt](https://github.com/StarHeartHunt) ([#3649](https://github.com/nonebot/nonebot2/pull/3649))
- Docs: 更新文档《手动创建项目》 [@Chen-Luan](https://github.com/Chen-Luan) ([#3623](https://github.com/nonebot/nonebot2/pull/3623)) - Docs: 更新文档《手动创建项目》 [@Chen-Luan](https://github.com/Chen-Luan) ([#3623](https://github.com/nonebot/nonebot2/pull/3623))
- Docs: 增加 B站直播间 适配器说明 [@MingxuanGame](https://github.com/MingxuanGame) ([#3636](https://github.com/nonebot/nonebot2/pull/3636)) - Docs: 增加 B站直播间 适配器说明 [@MingxuanGame](https://github.com/MingxuanGame) ([#3636](https://github.com/nonebot/nonebot2/pull/3636))
- Docs: 增加 VoceChat 适配器说明 [@5656565566](https://github.com/5656565566) ([#3627](https://github.com/nonebot/nonebot2/pull/3627)) - Docs: 增加 VoceChat 适配器说明 [@5656565566](https://github.com/5656565566) ([#3627](https://github.com/nonebot/nonebot2/pull/3627))

View File

@ -20,7 +20,6 @@ description: nonebot.adapters 模块
通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。 通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。
- **参数** - **参数**
- `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例 - `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例
- `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数 - `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数
@ -46,7 +45,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _property_ `config` {#Adapter-config} ### _property_ `config` {#Adapter-config}
@ -64,11 +62,9 @@ description: nonebot.adapters 模块
当有新的 [Bot](#Bot) 实例连接建立成功时调用。 当有新的 [Bot](#Bot) 实例连接建立成功时调用。
- **参数** - **参数**
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例 - `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
- **返回** - **返回**
- None - None
### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect} ### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect}
@ -80,11 +76,9 @@ description: nonebot.adapters 模块
当有 [Bot](#Bot) 实例连接断开时调用。 当有 [Bot](#Bot) 实例连接断开时调用。
- **参数** - **参数**
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例 - `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
- **返回** - **返回**
- None - None
### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server} ### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server}
@ -92,11 +86,9 @@ description: nonebot.adapters 模块
- **说明:** 设置一个 HTTP 服务器路由配置 - **说明:** 设置一个 HTTP 服务器路由配置
- **参数** - **参数**
- `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server}
@ -104,11 +96,9 @@ description: nonebot.adapters 模块
- **说明:** 设置一个 WebSocket 服务器路由配置 - **说明:** 设置一个 WebSocket 服务器路由配置
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup))
- **返回** - **返回**
- untyped - untyped
### _async method_ `request(setup)` {#Adapter-request} ### _async method_ `request(setup)` {#Adapter-request}
@ -116,11 +106,9 @@ description: nonebot.adapters 模块
- **说明:** 进行一个 HTTP 客户端请求 - **说明:** 进行一个 HTTP 客户端请求
- **参数** - **参数**
- `setup` ([Request](../drivers/index.md#Request)) - `setup` ([Request](../drivers/index.md#Request))
- **返回** - **返回**
- [Response](../drivers/index.md#Response) - [Response](../drivers/index.md#Response)
### _method_ `websocket(setup)` {#Adapter-websocket} ### _method_ `websocket(setup)` {#Adapter-websocket}
@ -128,21 +116,17 @@ description: nonebot.adapters 模块
- **说明:** 建立一个 WebSocket 客户端连接请求 - **说明:** 建立一个 WebSocket 客户端连接请求
- **参数** - **参数**
- `setup` ([Request](../drivers/index.md#Request)) - `setup` ([Request](../drivers/index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None] - AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None]
### _method_ `on_ready(func)` {#Adapter-on-ready} ### _method_ `on_ready(func)` {#Adapter-on-ready}
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
## _abstract class_ `Bot(adapter, self_id)` {#Bot} ## _abstract class_ `Bot(adapter, self_id)` {#Bot}
@ -154,7 +138,6 @@ description: nonebot.adapters 模块
用于处理上报消息,并提供 API 调用接口。 用于处理上报消息,并提供 API 调用接口。
- **参数** - **参数**
- `adapter` ([Adapter](#Adapter)): 协议适配器实例 - `adapter` ([Adapter](#Adapter)): 协议适配器实例
- `self_id` (str): 机器人 ID - `self_id` (str): 机器人 ID
@ -188,13 +171,11 @@ description: nonebot.adapters 模块
- **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用 - **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
- **参数** - **参数**
- `api` (str): API 名称 - `api` (str): API 名称
- `**data` (Any): API 数据 - `**data` (Any): API 数据
- **返回** - **返回**
- Any - Any
- **用法** - **用法**
@ -209,7 +190,6 @@ description: nonebot.adapters 模块
- **说明:** 调用机器人基础发送消息接口 - **说明:** 调用机器人基础发送消息接口
- **参数** - **参数**
- `event` ([Event](#Event)): 上报事件 - `event` ([Event](#Event)): 上报事件
- `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息 - `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息
@ -217,7 +197,6 @@ description: nonebot.adapters 模块
- `**kwargs` (Any): 任意额外参数 - `**kwargs` (Any): 任意额外参数
- **返回** - **返回**
- Any - Any
### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api} ### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api}
@ -227,17 +206,14 @@ description: nonebot.adapters 模块
调用 api 预处理。 调用 api 预处理。
钩子函数参数: 钩子函数参数:
- bot: 当前 bot 对象 - bot: 当前 bot 对象
- api: 调用的 api 名称 - api: 调用的 api 名称
- data: api 调用的参数字典 - data: api 调用的参数字典
- **参数** - **参数**
- `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook)) - `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook))
- **返回** - **返回**
- [T_CallingAPIHook](../typing.md#T-CallingAPIHook) - [T_CallingAPIHook](../typing.md#T-CallingAPIHook)
### _classmethod_ `on_called_api(func)` {#Bot-on-called-api} ### _classmethod_ `on_called_api(func)` {#Bot-on-called-api}
@ -247,7 +223,6 @@ description: nonebot.adapters 模块
调用 api 后处理。 调用 api 后处理。
钩子函数参数: 钩子函数参数:
- bot: 当前 bot 对象 - bot: 当前 bot 对象
- exception: 调用 api 时发生的错误 - exception: 调用 api 时发生的错误
- api: 调用的 api 名称 - api: 调用的 api 名称
@ -255,11 +230,9 @@ description: nonebot.adapters 模块
- result: api 调用的返回 - result: api 调用的返回
- **参数** - **参数**
- `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook)) - `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook))
- **返回** - **返回**
- [T_CalledAPIHook](../typing.md#T-CalledAPIHook) - [T_CalledAPIHook](../typing.md#T-CalledAPIHook)
## _abstract class_ `Event(<auto>)` {#Event} ## _abstract class_ `Event(<auto>)` {#Event}
@ -279,7 +252,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_event_name()` {#Event-get-event-name} ### _abstract method_ `get_event_name()` {#Event-get-event-name}
@ -291,7 +263,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_event_description()` {#Event-get-event-description} ### _abstract method_ `get_event_description()` {#Event-get-event-description}
@ -303,7 +274,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _method_ `get_log_string()` {#Event-get-log-string} ### _method_ `get_log_string()` {#Event-get-log-string}
@ -320,11 +290,9 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
- **异常** - **异常**
- NoLogException: 希望 NoneBot 隐藏该事件日志 - NoLogException: 希望 NoneBot 隐藏该事件日志
### _abstract method_ `get_user_id()` {#Event-get-user-id} ### _abstract method_ `get_user_id()` {#Event-get-user-id}
@ -336,7 +304,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_session_id()` {#Event-get-session-id} ### _abstract method_ `get_session_id()` {#Event-get-session-id}
@ -348,7 +315,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_message()` {#Event-get-message} ### _abstract method_ `get_message()` {#Event-get-message}
@ -360,7 +326,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- [Message](#Message) - [Message](#Message)
### _method_ `get_plaintext()` {#Event-get-plaintext} ### _method_ `get_plaintext()` {#Event-get-plaintext}
@ -376,7 +341,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `is_tome()` {#Event-is-tome} ### _abstract method_ `is_tome()` {#Event-is-tome}
@ -388,7 +352,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- bool - bool
## _abstract class_ `Message(<auto>)` {#Message} ## _abstract class_ `Message(<auto>)` {#Message}
@ -396,7 +359,6 @@ description: nonebot.adapters 模块
- **说明:** 消息序列 - **说明:** 消息序列
- **参数** - **参数**
- `message`: 消息内容 - `message`: 消息内容
### _classmethod_ `template(format_string)` {#Message-template} ### _classmethod_ `template(format_string)` {#Message-template}
@ -410,11 +372,9 @@ description: nonebot.adapters 模块
可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。 可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。
- **参数** - **参数**
- `format_string` (str | TM): 格式化模板 - `format_string` (str | TM): 格式化模板
- **返回** - **返回**
- [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器 - [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器
### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class} ### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class}
@ -426,7 +386,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- type[TMS] - type[TMS]
### _abstract staticmethod_ `_construct(msg)` {#Message--construct} ### _abstract staticmethod_ `_construct(msg)` {#Message--construct}
@ -434,11 +393,9 @@ description: nonebot.adapters 模块
- **说明:** 构造消息数组 - **说明:** 构造消息数组
- **参数** - **参数**
- `msg` (str) - `msg` (str)
- **返回** - **返回**
- Iterable[TMS] - Iterable[TMS]
### _method_ `__getitem__(args)` {#Message---getitem--} ### _method_ `__getitem__(args)` {#Message---getitem--}
@ -446,53 +403,38 @@ description: nonebot.adapters 模块
- **重载** - **重载**
**1.** `(args) -> Self` **1.** `(args) -> Self`
- **参数** - **参数**
- `args` (str): 消息段类型 - `args` (str): 消息段类型
- **返回** - **返回**
- Self: 所有类型为 `args` 的消息段 - Self: 所有类型为 `args` 的消息段
**2.** `(args) -> TMS` **2.** `(args) -> TMS`
- **参数** - **参数**
- `args` (tuple[str, int]): 消息段类型和索引 - `args` (tuple[str, int]): 消息段类型和索引
- **返回** - **返回**
- TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个 - TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个
**3.** `(args) -> Self` **3.** `(args) -> Self`
- **参数** - **参数**
- `args` (tuple[str, slice]): 消息段类型和切片 - `args` (tuple[str, slice]): 消息段类型和切片
- **返回** - **返回**
- Self: 类型为 `args[0]` 的消息段切片 `args[1]` - Self: 类型为 `args[0]` 的消息段切片 `args[1]`
**4.** `(args) -> TMS` **4.** `(args) -> TMS`
- **参数** - **参数**
- `args` (int): 索引 - `args` (int): 索引
- **返回** - **返回**
- TMS: 第 `args` 个消息段 - TMS: 第 `args` 个消息段
**5.** `(args) -> Self` **5.** `(args) -> Self`
- **参数** - **参数**
- `args` (slice): 切片 - `args` (slice): 切片
- **返回** - **返回**
- Self: 消息切片 `args` - Self: 消息切片 `args`
### _method_ `__contains__(value)` {#Message---contains--} ### _method_ `__contains__(value)` {#Message---contains--}
@ -500,11 +442,9 @@ description: nonebot.adapters 模块
- **说明:** 检查消息段是否存在 - **说明:** 检查消息段是否存在
- **参数** - **参数**
- `value` (TMS | str): 消息段或消息段类型 - `value` (TMS | str): 消息段或消息段类型
- **返回** - **返回**
- bool: 消息内是否存在给定消息段或给定类型的消息段 - bool: 消息内是否存在给定消息段或给定类型的消息段
### _method_ `has(value)` {#Message-has} ### _method_ `has(value)` {#Message-has}
@ -512,11 +452,9 @@ description: nonebot.adapters 模块
- **说明:** 与 [`__contains__`](#Message---contains--) 相同 - **说明:** 与 [`__contains__`](#Message---contains--) 相同
- **参数** - **参数**
- `value` (TMS | str) - `value` (TMS | str)
- **返回** - **返回**
- bool - bool
### _method_ `index(value, *args)` {#Message-index} ### _method_ `index(value, *args)` {#Message-index}
@ -524,7 +462,6 @@ description: nonebot.adapters 模块
- **说明:** 索引消息段 - **说明:** 索引消息段
- **参数** - **参数**
- `value` (TMS | str): 消息段或者消息段类型 - `value` (TMS | str): 消息段或者消息段类型
- `*args` (SupportsIndex) - `*args` (SupportsIndex)
@ -532,11 +469,9 @@ description: nonebot.adapters 模块
- `arg`: start 与 end - `arg`: start 与 end
- **返回** - **返回**
- int: 索引 index - int: 索引 index
- **异常** - **异常**
- ValueError: 消息段不存在 - ValueError: 消息段不存在
### _method_ `get(type_, count=None)` {#Message-get} ### _method_ `get(type_, count=None)` {#Message-get}
@ -544,13 +479,11 @@ description: nonebot.adapters 模块
- **说明:** 获取指定类型的消息段 - **说明:** 获取指定类型的消息段
- **参数** - **参数**
- `type_` (str): 消息段类型 - `type_` (str): 消息段类型
- `count` (int | None): 获取个数 - `count` (int | None): 获取个数
- **返回** - **返回**
- Self: 构建的新消息 - Self: 构建的新消息
### _method_ `count(value)` {#Message-count} ### _method_ `count(value)` {#Message-count}
@ -558,11 +491,9 @@ description: nonebot.adapters 模块
- **说明:** 计算指定消息段的个数 - **说明:** 计算指定消息段的个数
- **参数** - **参数**
- `value` (TMS | str): 消息段或消息段类型 - `value` (TMS | str): 消息段或消息段类型
- **返回** - **返回**
- int: 个数 - int: 个数
### _method_ `only(value)` {#Message-only} ### _method_ `only(value)` {#Message-only}
@ -570,11 +501,9 @@ description: nonebot.adapters 模块
- **说明:** 检查消息中是否仅包含指定消息段 - **说明:** 检查消息中是否仅包含指定消息段
- **参数** - **参数**
- `value` (TMS | str): 指定消息段或消息段类型 - `value` (TMS | str): 指定消息段或消息段类型
- **返回** - **返回**
- bool: 是否仅包含指定消息段 - bool: 是否仅包含指定消息段
### _method_ `append(obj)` {#Message-append} ### _method_ `append(obj)` {#Message-append}
@ -582,11 +511,9 @@ description: nonebot.adapters 模块
- **说明:** 添加一个消息段到消息数组末尾。 - **说明:** 添加一个消息段到消息数组末尾。
- **参数** - **参数**
- `obj` (str | TMS): 要添加的消息段 - `obj` (str | TMS): 要添加的消息段
- **返回** - **返回**
- Self - Self
### _method_ `extend(obj)` {#Message-extend} ### _method_ `extend(obj)` {#Message-extend}
@ -594,11 +521,9 @@ description: nonebot.adapters 模块
- **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。 - **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。
- **参数** - **参数**
- `obj` (Self | Iterable[TMS]): 要添加的消息数组 - `obj` (Self | Iterable[TMS]): 要添加的消息数组
- **返回** - **返回**
- Self - Self
### _method_ `join(iterable)` {#Message-join} ### _method_ `join(iterable)` {#Message-join}
@ -606,11 +531,9 @@ description: nonebot.adapters 模块
- **说明:** 将多个消息连接并将自身作为分割 - **说明:** 将多个消息连接并将自身作为分割
- **参数** - **参数**
- `iterable` (Iterable[TMS | Self]): 要连接的消息 - `iterable` (Iterable[TMS | Self]): 要连接的消息
- **返回** - **返回**
- Self: 连接后的消息 - Self: 连接后的消息
### _method_ `copy()` {#Message-copy} ### _method_ `copy()` {#Message-copy}
@ -622,7 +545,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- Self - Self
### _method_ `include(*types)` {#Message-include} ### _method_ `include(*types)` {#Message-include}
@ -630,11 +552,9 @@ description: nonebot.adapters 模块
- **说明:** 过滤消息 - **说明:** 过滤消息
- **参数** - **参数**
- `*types` (str): 包含的消息段类型 - `*types` (str): 包含的消息段类型
- **返回** - **返回**
- Self: 新构造的消息 - Self: 新构造的消息
### _method_ `exclude(*types)` {#Message-exclude} ### _method_ `exclude(*types)` {#Message-exclude}
@ -642,11 +562,9 @@ description: nonebot.adapters 模块
- **说明:** 过滤消息 - **说明:** 过滤消息
- **参数** - **参数**
- `*types` (str): 不包含的消息段类型 - `*types` (str): 不包含的消息段类型
- **返回** - **返回**
- Self: 新构造的消息 - Self: 新构造的消息
### _method_ `extract_plain_text()` {#Message-extract-plain-text} ### _method_ `extract_plain_text()` {#Message-extract-plain-text}
@ -658,7 +576,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment} ## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment}
@ -690,7 +607,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- type[TM] - type[TM]
### _abstract method_ `__str__()` {#MessageSegment---str--} ### _abstract method_ `__str__()` {#MessageSegment---str--}
@ -702,29 +618,24 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _method_ `__add__(other)` {#MessageSegment---add--} ### _method_ `__add__(other)` {#MessageSegment---add--}
- **参数** - **参数**
- `other` (str | TMS | Iterable[TMS]) - `other` (str | TMS | Iterable[TMS])
- **返回** - **返回**
- TM - TM
### _method_ `get(key, default=None)` {#MessageSegment-get} ### _method_ `get(key, default=None)` {#MessageSegment-get}
- **参数** - **参数**
- `key` (str) - `key` (str)
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- untyped - untyped
### _method_ `keys()` {#MessageSegment-keys} ### _method_ `keys()` {#MessageSegment-keys}
@ -734,7 +645,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `values()` {#MessageSegment-values} ### _method_ `values()` {#MessageSegment-values}
@ -744,7 +654,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `items()` {#MessageSegment-items} ### _method_ `items()` {#MessageSegment-items}
@ -754,17 +663,14 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `join(iterable)` {#MessageSegment-join} ### _method_ `join(iterable)` {#MessageSegment-join}
- **参数** - **参数**
- `iterable` (Iterable[TMS | TM]) - `iterable` (Iterable[TMS | TM])
- **返回** - **返回**
- TM - TM
### _method_ `copy()` {#MessageSegment-copy} ### _method_ `copy()` {#MessageSegment-copy}
@ -774,7 +680,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- Self - Self
### _abstract method_ `is_text()` {#MessageSegment-is-text} ### _abstract method_ `is_text()` {#MessageSegment-is-text}
@ -786,7 +691,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- bool - bool
## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate} ## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate}
@ -794,7 +698,6 @@ description: nonebot.adapters 模块
- **说明:** 消息模板格式化实现类。 - **说明:** 消息模板格式化实现类。
- **参数** - **参数**
- `template` (str | TM): 模板 - `template` (str | TM): 模板
- `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str` - `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str`
@ -804,13 +707,11 @@ description: nonebot.adapters 模块
### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec} ### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec}
- **参数** - **参数**
- `spec` (FormatSpecFunc_T) - `spec` (FormatSpecFunc_T)
- `name` (str | None) - `name` (str | None)
- **返回** - **返回**
- FormatSpecFunc_T - FormatSpecFunc_T
### _method_ `format(*args, **kwargs)` {#MessageTemplate-format} ### _method_ `format(*args, **kwargs)` {#MessageTemplate-format}
@ -818,13 +719,11 @@ description: nonebot.adapters 模块
- **说明:** 根据传入参数和模板生成消息对象 - **说明:** 根据传入参数和模板生成消息对象
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- TF - TF
### _method_ `format_map(mapping)` {#MessageTemplate-format-map} ### _method_ `format_map(mapping)` {#MessageTemplate-format-map}
@ -832,17 +731,14 @@ description: nonebot.adapters 模块
- **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用 - **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用
- **参数** - **参数**
- `mapping` (Mapping[str, Any]) - `mapping` (Mapping[str, Any])
- **返回** - **返回**
- TF - TF
### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat} ### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat}
- **参数** - **参数**
- `format_string` (str) - `format_string` (str)
- `args` (Sequence[Any]) - `args` (Sequence[Any])
@ -850,13 +746,11 @@ description: nonebot.adapters 模块
- `kwargs` (Mapping[str, Any]) - `kwargs` (Mapping[str, Any])
- **返回** - **返回**
- TF - TF
### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field} ### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field}
- **参数** - **参数**
- `field_name` (str) - `field_name` (str)
- `args` (Sequence[Any]) - `args` (Sequence[Any])
@ -864,17 +758,14 @@ description: nonebot.adapters 模块
- `kwargs` (Mapping[str, Any]) - `kwargs` (Mapping[str, Any])
- **返回** - **返回**
- tuple[Any, int | str] - tuple[Any, int | str]
### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field} ### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field}
- **参数** - **参数**
- `value` (Any) - `value` (Any)
- `format_spec` (str) - `format_spec` (str)
- **返回** - **返回**
- Any - Any

View File

@ -36,7 +36,6 @@ description: nonebot.compat 模块
- **说明:** FieldInfo class with extra property for compatibility with pydantic v1 - **说明:** FieldInfo class with extra property for compatibility with pydantic v1
- **参数** - **参数**
- `default` (Any) - `default` (Any)
- `**kwargs` (Any) - `**kwargs` (Any)
@ -82,7 +81,6 @@ description: nonebot.compat 模块
- **说明:** Construct a ModelField from given infos. - **说明:** Construct a ModelField from given infos.
- **参数** - **参数**
- `name` (str) - `name` (str)
- `annotation` (Any) - `annotation` (Any)
@ -90,7 +88,6 @@ description: nonebot.compat 模块
- `field_info` (FieldInfo | None) - `field_info` (FieldInfo | None)
- **返回** - **返回**
- Self - Self
### _method_ `get_default()` {#ModelField-get-default} ### _method_ `get_default()` {#ModelField-get-default}
@ -102,7 +99,6 @@ description: nonebot.compat 模块
empty empty
- **返回** - **返回**
- Any - Any
### _method_ `validate_value(value)` {#ModelField-validate-value} ### _method_ `validate_value(value)` {#ModelField-validate-value}
@ -110,11 +106,9 @@ description: nonebot.compat 模块
- **说明:** Validate the value pass to the field. - **说明:** Validate the value pass to the field.
- **参数** - **参数**
- `value` (Any) - `value` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `extract_field_info(field_info)` {#extract-field-info} ## _def_ `extract_field_info(field_info)` {#extract-field-info}
@ -122,11 +116,9 @@ description: nonebot.compat 模块
- **说明:** Get FieldInfo init kwargs from a FieldInfo instance. - **说明:** Get FieldInfo init kwargs from a FieldInfo instance.
- **参数** - **参数**
- `field_info` (BaseFieldInfo) - `field_info` (BaseFieldInfo)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `model_fields(model)` {#model-fields} ## _def_ `model_fields(model)` {#model-fields}
@ -134,11 +126,9 @@ description: nonebot.compat 模块
- **说明:** Get field list of a model. - **说明:** Get field list of a model.
- **参数** - **参数**
- `model` (type[BaseModel]) - `model` (type[BaseModel])
- **返回** - **返回**
- list[ModelField] - list[ModelField]
## _def_ `model_config(model)` {#model-config} ## _def_ `model_config(model)` {#model-config}
@ -146,17 +136,14 @@ description: nonebot.compat 模块
- **说明:** Get config of a model. - **说明:** Get config of a model.
- **参数** - **参数**
- `model` (type[BaseModel]) - `model` (type[BaseModel])
- **返回** - **返回**
- Any - Any
## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump} ## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump}
- **参数** - **参数**
- `model` (BaseModel) - `model` (BaseModel)
- `include` (set[str] | None) - `include` (set[str] | None)
@ -172,7 +159,6 @@ description: nonebot.compat 模块
- `exclude_none` (bool) - `exclude_none` (bool)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `type_validate_python(type_, data)` {#type-validate-python} ## _def_ `type_validate_python(type_, data)` {#type-validate-python}
@ -180,13 +166,11 @@ description: nonebot.compat 模块
- **说明:** Validate data with given type. - **说明:** Validate data with given type.
- **参数** - **参数**
- `type_` (type[T]) - `type_` (type[T])
- `data` (Any) - `data` (Any)
- **返回** - **返回**
- T - T
## _def_ `type_validate_json(type_, data)` {#type-validate-json} ## _def_ `type_validate_json(type_, data)` {#type-validate-json}
@ -194,13 +178,11 @@ description: nonebot.compat 模块
- **说明:** Validate JSON with given type. - **说明:** Validate JSON with given type.
- **参数** - **参数**
- `type_` (type[T]) - `type_` (type[T])
- `data` (str | bytes) - `data` (str | bytes)
- **返回** - **返回**
- T - T
## _def_ `custom_validation(class_)` {#custom-validation} ## _def_ `custom_validation(class_)` {#custom-validation}
@ -208,9 +190,7 @@ description: nonebot.compat 模块
- **说明:** Use pydantic v1 like validator generator in pydantic v2 - **说明:** Use pydantic v1 like validator generator in pydantic v2
- **参数** - **参数**
- `class_` (type[CVC]) - `class_` (type[CVC])
- **返回** - **返回**
- type[CVC] - type[CVC]

View File

@ -24,7 +24,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。 将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None) - `_env_file` (DOTENV_TYPE | None)
- `_env_file_encoding` (str | None) - `_env_file_encoding` (str | None)
@ -55,7 +54,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
配置方法参考: [配置](https://nonebot.dev/docs/appendices/config) 配置方法参考: [配置](https://nonebot.dev/docs/appendices/config)
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None) - `_env_file` (DOTENV_TYPE | None)
- `_env_file_encoding` (str | None) - `_env_file_encoding` (str | None)

View File

@ -18,7 +18,6 @@ description: nonebot.dependencies 模块
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。 继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -30,7 +29,6 @@ description: nonebot.dependencies 模块
- **说明:** 依赖注入容器 - **说明:** 依赖注入容器
- **参数** - **参数**
- `call`: 依赖注入的可调用对象,可以是任何 Callable 对象 - `call`: 依赖注入的可调用对象,可以是任何 Callable 对象
- `pre_checkers`: 依赖注入解析前的参数检查 - `pre_checkers`: 依赖注入解析前的参数检查
@ -44,31 +42,26 @@ description: nonebot.dependencies 模块
### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params} ### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params}
- **参数** - **参数**
- `call` (\_DependentCallable[R]) - `call` (\_DependentCallable[R])
- `allow_types` (tuple[type[Param], ...]) - `allow_types` (tuple[type[Param], ...])
- **返回** - **返回**
- tuple[[ModelField](../compat.md#ModelField), ...] - tuple[[ModelField](../compat.md#ModelField), ...]
### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless} ### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless}
- **参数** - **参数**
- `parameterless` (tuple[Any, ...]) - `parameterless` (tuple[Any, ...])
- `allow_types` (tuple[type[Param], ...]) - `allow_types` (tuple[type[Param], ...])
- **返回** - **返回**
- tuple[Param, ...] - tuple[Param, ...]
### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse} ### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse}
- **参数** - **参数**
- `call` (\_DependentCallable[R]) - `call` (\_DependentCallable[R])
- `parameterless` (Iterable[Any] | None) - `parameterless` (Iterable[Any] | None)
@ -76,25 +69,20 @@ description: nonebot.dependencies 模块
- `allow_types` (Iterable[type[Param]]) - `allow_types` (Iterable[type[Param]])
- **返回** - **返回**
- Dependent[R] - Dependent[R]
### _async method_ `check(**params)` {#Dependent-check} ### _async method_ `check(**params)` {#Dependent-check}
- **参数** - **参数**
- `**params` (Any) - `**params` (Any)
- **返回** - **返回**
- None - None
### _async method_ `solve(**params)` {#Dependent-solve} ### _async method_ `solve(**params)` {#Dependent-solve}
- **参数** - **参数**
- `**params` (Any) - `**params` (Any)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]

View File

@ -12,11 +12,9 @@ description: nonebot.dependencies.utils 模块
- **说明:** 获取可调用对象签名 - **说明:** 获取可调用对象签名
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- inspect.Signature - inspect.Signature
## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation} ## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation}
@ -24,13 +22,11 @@ description: nonebot.dependencies.utils 模块
- **说明:** 获取参数的类型注解 - **说明:** 获取参数的类型注解
- **参数** - **参数**
- `param` (inspect.Parameter) - `param` (inspect.Parameter)
- `globalns` (dict[str, Any]) - `globalns` (dict[str, Any])
- **返回** - **返回**
- Any - Any
## _def_ `check_field_type(field, value)` {#check-field-type} ## _def_ `check_field_type(field, value)` {#check-field-type}
@ -38,11 +34,9 @@ description: nonebot.dependencies.utils 模块
- **说明:** 检查字段类型是否匹配 - **说明:** 检查字段类型是否匹配
- **参数** - **参数**
- `field` ([ModelField](../compat.md#ModelField)) - `field` ([ModelField](../compat.md#ModelField))
- `value` (Any) - `value` (Any)
- **返回** - **返回**
- Any - Any

View File

@ -22,7 +22,6 @@ pip install nonebot2[aiohttp]
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session} ## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -38,11 +37,9 @@ pip install nonebot2[aiohttp]
### _async method_ `request(setup)` {#Session-request} ### _async method_ `request(setup)` {#Session-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _async method_ `setup()` {#Session-setup} ### _async method_ `setup()` {#Session-setup}
@ -52,7 +49,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close()` {#Session-close} ### _async method_ `close()` {#Session-close}
@ -62,7 +58,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- None - None
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -76,27 +71,22 @@ pip install nonebot2[aiohttp]
### _async method_ `request(setup)` {#Mixin-request} ### _async method_ `request(setup)` {#Mixin-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `websocket(setup)` {#Mixin-websocket} ### _method_ `websocket(setup)` {#Mixin-websocket}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](index.md#WebSocket), None] - AsyncGenerator[[WebSocket](index.md#WebSocket), None]
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session} ### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -110,7 +100,6 @@ pip install nonebot2[aiohttp]
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- Session - Session
## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket} ## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket}
@ -118,7 +107,6 @@ pip install nonebot2[aiohttp]
- **说明:** AIOHTTP Websocket Wrapper - **说明:** AIOHTTP Websocket Wrapper
- **参数** - **参数**
- `request` ([Request](index.md#Request)) - `request` ([Request](index.md#Request))
- `session` (aiohttp.ClientSession) - `session` (aiohttp.ClientSession)
@ -132,19 +120,16 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -154,7 +139,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -164,7 +148,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -174,33 +157,27 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -92,7 +92,6 @@ pip install nonebot2[fastapi]
- **说明:** FastAPI 驱动框架。 - **说明:** FastAPI 驱动框架。
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` (NoneBotConfig) - `config` (NoneBotConfig)
@ -124,21 +123,17 @@ pip install nonebot2[fastapi]
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server} ### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
- **参数** - **参数**
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
- **返回** - **返回**
- None - None
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run} ### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
@ -146,7 +141,6 @@ pip install nonebot2[fastapi]
- **说明:** 使用 `uvicorn` 启动 FastAPI - **说明:** 使用 `uvicorn` 启动 FastAPI
- **参数** - **参数**
- `host` (str | None) - `host` (str | None)
- `port` (int | None) - `port` (int | None)
@ -158,7 +152,6 @@ pip install nonebot2[fastapi]
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket} ## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket}
@ -166,7 +159,6 @@ pip install nonebot2[fastapi]
- **说明:** FastAPI WebSocket Wrapper - **说明:** FastAPI WebSocket Wrapper
- **参数** - **参数**
- `request` (BaseRequest) - `request` (BaseRequest)
- `websocket` ([WebSocket](index.md#WebSocket)) - `websocket` ([WebSocket](index.md#WebSocket))
@ -178,19 +170,16 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close} ### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- None - None
### _async method_ `receive()` {#FastAPIWebSocket-receive} ### _async method_ `receive()` {#FastAPIWebSocket-receive}
@ -200,7 +189,6 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text} ### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text}
@ -210,7 +198,6 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes}
@ -220,25 +207,20 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text} ### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None

View File

@ -22,7 +22,6 @@ pip install nonebot2[httpx]
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session} ## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -38,11 +37,9 @@ pip install nonebot2[httpx]
### _async method_ `request(setup)` {#Session-request} ### _async method_ `request(setup)` {#Session-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _async method_ `setup()` {#Session-setup} ### _async method_ `setup()` {#Session-setup}
@ -52,7 +49,6 @@ pip install nonebot2[httpx]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close()` {#Session-close} ### _async method_ `close()` {#Session-close}
@ -62,7 +58,6 @@ pip install nonebot2[httpx]
empty empty
- **返回** - **返回**
- None - None
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -76,17 +71,14 @@ pip install nonebot2[httpx]
### _async method_ `request(setup)` {#Mixin-request} ### _async method_ `request(setup)` {#Mixin-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session} ### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -100,13 +92,11 @@ pip install nonebot2[httpx]
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- Session - Session
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -40,11 +40,9 @@ description: nonebot.drivers 模块
- **说明:** 设置一个 HTTP 服务器路由配置 - **说明:** 设置一个 HTTP 服务器路由配置
- **参数** - **参数**
- `setup` ([HTTPServerSetup](#HTTPServerSetup)) - `setup` ([HTTPServerSetup](#HTTPServerSetup))
- **返回** - **返回**
- None - None
### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server} ### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server}
@ -52,23 +50,19 @@ description: nonebot.drivers 模块
- **说明:** 设置一个 WebSocket 服务器路由配置 - **说明:** 设置一个 WebSocket 服务器路由配置
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](#WebSocketServerSetup))
- **返回** - **返回**
- None - None
## _class_ `Cookies(cookies=None)` {#Cookies} ## _class_ `Cookies(cookies=None)` {#Cookies}
- **参数** - **参数**
- `cookies` (CookieTypes) - `cookies` (CookieTypes)
### _method_ `set(name, value, domain="", path="/")` {#Cookies-set} ### _method_ `set(name, value, domain="", path="/")` {#Cookies-set}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `value` (str) - `value` (str)
@ -78,13 +72,11 @@ description: nonebot.drivers 模块
- `path` (str) - `path` (str)
- **返回** - **返回**
- None - None
### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get} ### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `default` (str | None) - `default` (str | None)
@ -94,13 +86,11 @@ description: nonebot.drivers 模块
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- str | None - str | None
### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete} ### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `domain` (str | None) - `domain` (str | None)
@ -108,39 +98,32 @@ description: nonebot.drivers 模块
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- None - None
### _method_ `clear(domain=None, path=None)` {#Cookies-clear} ### _method_ `clear(domain=None, path=None)` {#Cookies-clear}
- **参数** - **参数**
- `domain` (str | None) - `domain` (str | None)
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- None - None
### _method_ `update(cookies=None)` {#Cookies-update} ### _method_ `update(cookies=None)` {#Cookies-update}
- **参数** - **参数**
- `cookies` (CookieTypes) - `cookies` (CookieTypes)
- **返回** - **返回**
- None - None
### _method_ `as_header(request)` {#Cookies-as-header} ### _method_ `as_header(request)` {#Cookies-as-header}
- **参数** - **参数**
- `request` (Request) - `request` (Request)
- **返回** - **返回**
- dict[str, str] - dict[str, str]
## _abstract class_ `Driver(env, config)` {#Driver} ## _abstract class_ `Driver(env, config)` {#Driver}
@ -152,7 +135,6 @@ description: nonebot.drivers 模块
驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。 驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。
- **参数** - **参数**
- `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象 - `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象
- `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象 - `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象
@ -180,13 +162,11 @@ description: nonebot.drivers 模块
- **说明:** 注册一个协议适配器 - **说明:** 注册一个协议适配器
- **参数** - **参数**
- `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类 - `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类
- `**kwargs`: 其他传递给适配器的参数 - `**kwargs`: 其他传递给适配器的参数
- **返回** - **返回**
- None - None
### _abstract property_ `type` {#Driver-type} ### _abstract property_ `type` {#Driver-type}
@ -206,13 +186,11 @@ description: nonebot.drivers 模块
- **说明:** 启动驱动框架 - **说明:** 启动驱动框架
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
### _method_ `on_startup(func)` {#Driver-on-startup} ### _method_ `on_startup(func)` {#Driver-on-startup}
@ -220,11 +198,9 @@ description: nonebot.drivers 模块
- **说明:** 注册一个启动时执行的函数 - **说明:** 注册一个启动时执行的函数
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
### _method_ `on_shutdown(func)` {#Driver-on-shutdown} ### _method_ `on_shutdown(func)` {#Driver-on-shutdown}
@ -232,11 +208,9 @@ description: nonebot.drivers 模块
- **说明:** 注册一个停止时执行的函数 - **说明:** 注册一个停止时执行的函数
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect} ### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect}
@ -246,15 +220,12 @@ description: nonebot.drivers 模块
装饰一个函数使他在 bot 连接成功时执行。 装饰一个函数使他在 bot 连接成功时执行。
钩子函数参数: 钩子函数参数:
- bot: 当前连接上的 Bot 对象 - bot: 当前连接上的 Bot 对象
- **参数** - **参数**
- `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook)) - `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook))
- **返回** - **返回**
- [T_BotConnectionHook](../typing.md#T-BotConnectionHook) - [T_BotConnectionHook](../typing.md#T-BotConnectionHook)
### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect} ### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect}
@ -264,15 +235,12 @@ description: nonebot.drivers 模块
装饰一个函数使他在 bot 连接断开时执行。 装饰一个函数使他在 bot 连接断开时执行。
钩子函数参数: 钩子函数参数:
- bot: 当前连接上的 Bot 对象 - bot: 当前连接上的 Bot 对象
- **参数** - **参数**
- `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)) - `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook))
- **返回** - **返回**
- [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook) - [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)
## _var_ `ForwardDriver` {#ForwardDriver} ## _var_ `ForwardDriver` {#ForwardDriver}
@ -306,11 +274,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一个 HTTP 请求 - **说明:** 发送一个 HTTP 请求
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- **返回** - **返回**
- [Response](#Response) - [Response](#Response)
### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session} ### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session}
@ -318,7 +284,6 @@ description: nonebot.drivers 模块
- **说明:** 获取一个 HTTP 会话 - **说明:** 获取一个 HTTP 会话
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -332,7 +297,6 @@ description: nonebot.drivers 模块
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- HTTPClientSession - HTTPClientSession
## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup} ## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup}
@ -350,7 +314,6 @@ description: nonebot.drivers 模块
- **参数** - **参数**
auto auto
- `H10: '1.0'` - `H10: '1.0'`
- `H11: '1.1'` - `H11: '1.1'`
@ -374,7 +337,6 @@ description: nonebot.drivers 模块
## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request} ## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request}
- **参数** - **参数**
- `method` (str | bytes) - `method` (str | bytes)
- `url` (URL | str | RawURL) - `url` (URL | str | RawURL)
@ -402,7 +364,6 @@ description: nonebot.drivers 模块
## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response} ## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response}
- **参数** - **参数**
- `status_code` (int) - `status_code` (int)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -432,7 +393,6 @@ description: nonebot.drivers 模块
## _abstract class_ `WebSocket(*, request)` {#WebSocket} ## _abstract class_ `WebSocket(*, request)` {#WebSocket}
- **参数** - **参数**
- `request` (Request) - `request` (Request)
### _abstract property_ `closed` {#WebSocket-closed} ### _abstract property_ `closed` {#WebSocket-closed}
@ -450,7 +410,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- None - None
### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close}
@ -458,13 +417,11 @@ description: nonebot.drivers 模块
- **说明:** 关闭 WebSocket 连接请求 - **说明:** 关闭 WebSocket 连接请求
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- None - None
### _abstract async method_ `receive()` {#WebSocket-receive} ### _abstract async method_ `receive()` {#WebSocket-receive}
@ -476,7 +433,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _abstract async method_ `receive_text()` {#WebSocket-receive-text} ### _abstract async method_ `receive_text()` {#WebSocket-receive-text}
@ -488,7 +444,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -500,7 +455,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send(data)` {#WebSocket-send} ### _async method_ `send(data)` {#WebSocket-send}
@ -508,11 +462,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket text/bytes 信息 - **说明:** 发送一条 WebSocket text/bytes 信息
- **参数** - **参数**
- `data` (str | bytes) - `data` (str | bytes)
- **返回** - **返回**
- None - None
### _abstract async method_ `send_text(data)` {#WebSocket-send-text} ### _abstract async method_ `send_text(data)` {#WebSocket-send-text}
@ -520,11 +472,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket text 信息 - **说明:** 发送一条 WebSocket text 信息
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes}
@ -532,11 +482,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket binary 信息 - **说明:** 发送一条 WebSocket binary 信息
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin} ## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin}
@ -552,11 +500,9 @@ description: nonebot.drivers 模块
- **说明:** 发起一个 WebSocket 连接 - **说明:** 发起一个 WebSocket 连接
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](#WebSocket), None] - AsyncGenerator[[WebSocket](#WebSocket), None]
## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup} ## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup}
@ -574,19 +520,14 @@ description: nonebot.drivers 模块
- **重载** - **重载**
**1.** `(driver) -> type[D]` **1.** `(driver) -> type[D]`
- **参数** - **参数**
- `driver` (type[D]) - `driver` (type[D])
- **返回** - **返回**
- type[D] - type[D]
**2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]` **2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]`
- **参数** - **参数**
- `driver` (type[D]) - `driver` (type[D])
- `__m` (type[[Mixin](#Mixin)]) - `__m` (type[[Mixin](#Mixin)])
@ -594,5 +535,4 @@ description: nonebot.drivers 模块
- `*mixins` (type[[Mixin](#Mixin)]) - `*mixins` (type[[Mixin](#Mixin)])
- **返回** - **返回**
- type[CombinedDriver] - type[CombinedDriver]

View File

@ -18,7 +18,6 @@ None 驱动适配
- **说明:** None 驱动框架 - **说明:** None 驱动框架
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))
@ -40,13 +39,11 @@ None 驱动适配
- **说明:** 启动 none driver - **说明:** 启动 none driver
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
### _method_ `exit(force=False)` {#Driver-exit} ### _method_ `exit(force=False)` {#Driver-exit}
@ -54,9 +51,7 @@ None 驱动适配
- **说明:** 退出 none driver - **说明:** 退出 none driver
- **参数** - **参数**
- `force` (bool): 强制退出 - `force` (bool): 强制退出
- **返回** - **返回**
- untyped - untyped

View File

@ -68,7 +68,6 @@ pip install nonebot2[quart]
- **说明:** Quart 驱动框架 - **说明:** Quart 驱动框架
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` (NoneBotConfig) - `config` (NoneBotConfig)
@ -100,21 +99,17 @@ pip install nonebot2[quart]
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server} ### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
- **参数** - **参数**
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
- **返回** - **返回**
- None - None
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run} ### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
@ -122,7 +117,6 @@ pip install nonebot2[quart]
- **说明:** 使用 `uvicorn` 启动 Quart - **说明:** 使用 `uvicorn` 启动 Quart
- **参数** - **参数**
- `host` (str | None) - `host` (str | None)
- `port` (int | None) - `port` (int | None)
@ -134,7 +128,6 @@ pip install nonebot2[quart]
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket} ## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket}
@ -142,7 +135,6 @@ pip install nonebot2[quart]
- **说明:** Quart WebSocket Wrapper - **说明:** Quart WebSocket Wrapper
- **参数** - **参数**
- `request` (BaseRequest) - `request` (BaseRequest)
- `websocket_ctx` (WebsocketContext) - `websocket_ctx` (WebsocketContext)
@ -154,19 +146,16 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -176,7 +165,6 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -186,7 +174,6 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -196,25 +183,20 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- untyped - untyped

View File

@ -22,11 +22,9 @@ pip install nonebot2[websockets]
## _def_ `catch_closed(func)` {#catch-closed} ## _def_ `catch_closed(func)` {#catch-closed}
- **参数** - **参数**
- `func` ((P) -> Coroutine[Any, Any, T]) - `func` ((P) -> Coroutine[Any, Any, T])
- **返回** - **返回**
- (P) -> Coroutine[Any, Any, T] - (P) -> Coroutine[Any, Any, T]
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -40,11 +38,9 @@ pip install nonebot2[websockets]
### _method_ `websocket(setup)` {#Mixin-websocket} ### _method_ `websocket(setup)` {#Mixin-websocket}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](index.md#WebSocket), None] - AsyncGenerator[[WebSocket](index.md#WebSocket), None]
## _class_ `WebSocket(*, request, websocket)` {#WebSocket} ## _class_ `WebSocket(*, request, websocket)` {#WebSocket}
@ -52,7 +48,6 @@ pip install nonebot2[websockets]
- **说明:** Websockets WebSocket Wrapper - **说明:** Websockets WebSocket Wrapper
- **参数** - **参数**
- `request` ([Request](index.md#Request)) - `request` ([Request](index.md#Request))
- `websocket` (WebSocketClientProtocol) - `websocket` (WebSocketClientProtocol)
@ -64,19 +59,16 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -86,7 +78,6 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -96,7 +87,6 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -106,33 +96,27 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -62,7 +62,6 @@ NoneBotException
- **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。 - **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
- **参数** - **参数**
- `reason`: 忽略事件的原因 - `reason`: 忽略事件的原因
## _class_ `SkippedException(<auto>)` {#SkippedException} ## _class_ `SkippedException(<auto>)` {#SkippedException}
@ -101,7 +100,6 @@ NoneBotException
- **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。 - **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。
- **参数** - **参数**
- `result`: 返回的内容 - `result`: 返回的内容
## _class_ `StopPropagation(<auto>)` {#StopPropagation} ## _class_ `StopPropagation(<auto>)` {#StopPropagation}
@ -200,7 +198,6 @@ NoneBotException
- **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。 - **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。
- **参数** - **参数**
- `adapter_name`: 标识 adapter - `adapter_name`: 标识 adapter
## _class_ `NoLogException(<auto>)` {#NoLogException} ## _class_ `NoLogException(<auto>)` {#NoLogException}

View File

@ -60,11 +60,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象 - [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -80,27 +78,20 @@ description: nonebot 模块
- **重载** - **重载**
**1.** `(name) -> Adapter` **1.** `(name) -> Adapter`
- **参数** - **参数**
- `name` (str): 适配器名称 - `name` (str): 适配器名称
- **返回** - **返回**
- [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象 - [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象
**2.** `(name) -> A` **2.** `(name) -> A`
- **参数** - **参数**
- `name` (type[A]): 适配器类型 - `name` (type[A]): 适配器类型
- **返回** - **返回**
- A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象 - A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象
- **异常** - **异常**
- ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册 - ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -121,11 +112,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典 - dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -143,11 +132,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- Any: Server App 对象 - Any: Server App 对象
- **异常** - **异常**
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型 - AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -167,11 +154,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- Any: ASGI 对象 - Any: ASGI 对象
- **异常** - **异常**
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型 - AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -192,15 +177,12 @@ description: nonebot 模块
当不提供时,返回一个 [Bot](adapters/index.md#Bot)。 当不提供时,返回一个 [Bot](adapters/index.md#Bot)。
- **参数** - **参数**
- `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性 - `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性
- **返回** - **返回**
- [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象 - [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象
- **异常** - **异常**
- KeyError: 对应 self_id 的 Bot 不存在 - KeyError: 对应 self_id 的 Bot 不存在
- ValueError: 没有传入 self_id 且没有 Bot 可用 - ValueError: 没有传入 self_id 且没有 Bot 可用
@ -224,13 +206,11 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键 - dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键
[Bot](adapters/index.md#Bot) 对象为值的字典 [Bot](adapters/index.md#Bot) 对象为值的字典
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -250,13 +230,11 @@ description: nonebot 模块
也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。 也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置 - `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置
- `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里 - `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里
- **返回** - **返回**
- None - None
- **用法** - **用法**
@ -270,13 +248,11 @@ description: nonebot 模块
- **说明:** 启动 NoneBot即运行全局 [Driver](drivers/index.md#Driver) 对象。 - **说明:** 启动 NoneBot即运行全局 [Driver](drivers/index.md#Driver) 对象。
- **参数** - **参数**
- `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数 - `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数
- `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数 - `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数
- **返回** - **返回**
- None - None
- **用法** - **用法**

View File

@ -25,7 +25,6 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
NoneBot 日志记录器对象。 NoneBot 日志记录器对象。
默认信息: 默认信息:
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s` - 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
- 等级: `INFO` ,根据 `config.log_level` 配置改变 - 等级: `INFO` ,根据 `config.log_level` 配置改变
- 输出: 输出至 stdout - 输出: 输出至 stdout
@ -47,11 +46,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
### _method_ `emit(record)` {#LoguruHandler-emit} ### _method_ `emit(record)` {#LoguruHandler-emit}
- **参数** - **参数**
- `record` (logging.LogRecord) - `record` (logging.LogRecord)
- **返回** - **返回**
- untyped - untyped
## _def_ `default_filter(record)` {#default-filter} ## _def_ `default_filter(record)` {#default-filter}
@ -59,11 +56,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
- **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。 - **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
- **参数** - **参数**
- `record` (Record) - `record` (Record)
- **返回** - **返回**
- untyped - untyped
## _var_ `default_format` {#default-format} ## _var_ `default_format` {#default-format}

View File

@ -76,7 +76,6 @@ description: nonebot.matcher 模块
- **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_ - **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_
- **参数** - **参数**
- `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意 - `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意
- `rule` ([Rule](rule.md#Rule) | None): 匹配规则 - `rule` ([Rule](rule.md#Rule) | None): 匹配规则
@ -106,7 +105,6 @@ description: nonebot.matcher 模块
- `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数 - `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数
- **返回** - **返回**
- type[Matcher]: 新的事件响应器类 - type[Matcher]: 新的事件响应器类
### _classmethod_ `destroy()` {#Matcher-destroy} ### _classmethod_ `destroy()` {#Matcher-destroy}
@ -118,7 +116,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- None - None
### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm} ### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm}
@ -126,7 +123,6 @@ description: nonebot.matcher 模块
- **说明:** 检查是否满足触发权限 - **说明:** 检查是否满足触发权限
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): 上报事件 - `event` ([Event](adapters/index.md#Event)): 上报事件
@ -136,7 +132,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool: 是否满足权限 - bool: 是否满足权限
### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule} ### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule}
@ -144,7 +139,6 @@ description: nonebot.matcher 模块
- **说明:** 检查是否满足匹配规则 - **说明:** 检查是否满足匹配规则
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): 上报事件 - `event` ([Event](adapters/index.md#Event)): 上报事件
@ -156,7 +150,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool: 是否满足匹配规则 - bool: 是否满足匹配规则
### _classmethod_ `type_updater(func)` {#Matcher-type-updater} ### _classmethod_ `type_updater(func)` {#Matcher-type-updater}
@ -164,11 +157,9 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数 - **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数
- **参数** - **参数**
- `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数 - `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数
- **返回** - **返回**
- [T_TypeUpdater](typing.md#T-TypeUpdater) - [T_TypeUpdater](typing.md#T-TypeUpdater)
### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater} ### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater}
@ -176,23 +167,19 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数 - **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数
- **参数** - **参数**
- `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数 - `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数
- **返回** - **返回**
- [T_PermissionUpdater](typing.md#T-PermissionUpdater) - [T_PermissionUpdater](typing.md#T-PermissionUpdater)
### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler} ### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler}
- **参数** - **参数**
- `handler` ([T_Handler](typing.md#T-Handler)) - `handler` ([T_Handler](typing.md#T-Handler))
- `parameterless` (Iterable[Any] | None) - `parameterless` (Iterable[Any] | None)
- **返回** - **返回**
- [Dependent](dependencies/index.md#Dependent)[Any] - [Dependent](dependencies/index.md#Dependent)[Any]
### _classmethod_ `handle(parameterless=None)` {#Matcher-handle} ### _classmethod_ `handle(parameterless=None)` {#Matcher-handle}
@ -200,11 +187,9 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数 - **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数
- **参数** - **参数**
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive} ### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive}
@ -212,13 +197,11 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数 - **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
- **参数** - **参数**
- `id` (str): 消息 ID - `id` (str): 消息 ID
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got} ### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got}
@ -231,7 +214,6 @@ description: nonebot.matcher 模块
如果 `key` 已存在则直接继续运行 如果 `key` 已存在则直接继续运行
- **参数** - **参数**
- `key` (str): 参数名 - `key` (str): 参数名
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息
@ -239,7 +221,6 @@ description: nonebot.matcher 模块
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `send(message, **kwargs)` {#Matcher-send} ### _classmethod_ `send(message, **kwargs)` {#Matcher-send}
@ -247,13 +228,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户 - **说明:** 发送一条消息给当前交互用户
- **参数** - **参数**
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容 - `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容
- `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- Any - Any
### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish} ### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish}
@ -261,13 +240,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户并结束当前事件响应器 - **说明:** 发送一条消息给当前交互用户并结束当前事件响应器
- **参数** - **参数**
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause} ### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause}
@ -275,13 +252,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数 - **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
- **参数** - **参数**
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject} ### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject}
@ -289,13 +264,11 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数 - **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
- **参数** - **参数**
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg} ### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg}
@ -303,7 +276,6 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数 - **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数
- **参数** - **参数**
- `key` (str): 参数名 - `key` (str): 参数名
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
@ -311,7 +283,6 @@ description: nonebot.matcher 模块
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive} ### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive}
@ -319,7 +290,6 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数 - **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
- **参数** - **参数**
- `id` (str): 消息 id - `id` (str): 消息 id
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
@ -327,7 +297,6 @@ description: nonebot.matcher 模块
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `skip()` {#Matcher-skip} ### _classmethod_ `skip()` {#Matcher-skip}
@ -343,7 +312,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- NoReturn - NoReturn
### _method_ `get_receive(id, default=None)` {#Matcher-get-receive} ### _method_ `get_receive(id, default=None)` {#Matcher-get-receive}
@ -357,25 +325,19 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(id) -> Event | None` **1.** `(id) -> Event | None`
- **参数** - **参数**
- `id` (str) - `id` (str)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | None - [Event](adapters/index.md#Event) | None
**2.** `(id, default) -> Event | T` **2.** `(id, default) -> Event | T`
- **参数** - **参数**
- `id` (str) - `id` (str)
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | T - [Event](adapters/index.md#Event) | T
### _method_ `set_receive(id, event)` {#Matcher-set-receive} ### _method_ `set_receive(id, event)` {#Matcher-set-receive}
@ -383,13 +345,11 @@ description: nonebot.matcher 模块
- **说明:** 设置一个 `receive` 事件 - **说明:** 设置一个 `receive` 事件
- **参数** - **参数**
- `id` (str) - `id` (str)
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
- **返回** - **返回**
- None - None
### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive} ### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive}
@ -403,23 +363,18 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `() -> Event | None` **1.** `() -> Event | None`
- **参数** - **参数**
empty empty
- **返回** - **返回**
- [Event](adapters/index.md#Event) | None - [Event](adapters/index.md#Event) | None
**2.** `(default) -> Event | T` **2.** `(default) -> Event | T`
- **参数** - **参数**
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | T - [Event](adapters/index.md#Event) | T
### _method_ `get_arg(key, default=None)` {#Matcher-get-arg} ### _method_ `get_arg(key, default=None)` {#Matcher-get-arg}
@ -433,25 +388,19 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(key) -> Message | None` **1.** `(key) -> Message | None`
- **参数** - **参数**
- `key` (str) - `key` (str)
- **返回** - **返回**
- [Message](adapters/index.md#Message) | None - [Message](adapters/index.md#Message) | None
**2.** `(key, default) -> Message | T` **2.** `(key, default) -> Message | T`
- **参数** - **参数**
- `key` (str) - `key` (str)
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Message](adapters/index.md#Message) | T - [Message](adapters/index.md#Message) | T
### _method_ `set_arg(key, message)` {#Matcher-set-arg} ### _method_ `set_arg(key, message)` {#Matcher-set-arg}
@ -459,25 +408,21 @@ description: nonebot.matcher 模块
- **说明:** 设置一个 `got` 消息 - **说明:** 设置一个 `got` 消息
- **参数** - **参数**
- `key` (str) - `key` (str)
- `message` ([Message](adapters/index.md#Message)) - `message` ([Message](adapters/index.md#Message))
- **返回** - **返回**
- None - None
### _method_ `set_target(target, cache=True)` {#Matcher-set-target} ### _method_ `set_target(target, cache=True)` {#Matcher-set-target}
- **参数** - **参数**
- `target` (str) - `target` (str)
- `cache` (bool) - `cache` (bool)
- **返回** - **返回**
- None - None
### _method_ `get_target(default=None)` {#Matcher-get-target} ### _method_ `get_target(default=None)` {#Matcher-get-target}
@ -485,23 +430,18 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `() -> str | None` **1.** `() -> str | None`
- **参数** - **参数**
empty empty
- **返回** - **返回**
- str | None - str | None
**2.** `(default) -> str | T` **2.** `(default) -> str | T`
- **参数** - **参数**
- `default` (T) - `default` (T)
- **返回** - **返回**
- str | T - str | T
### _method_ `stop_propagation()` {#Matcher-stop-propagation} ### _method_ `stop_propagation()` {#Matcher-stop-propagation}
@ -513,13 +453,11 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type} ### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -529,13 +467,11 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- str - str
### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission} ### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -545,7 +481,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- [Permission](permission.md#Permission) - [Permission](permission.md#Permission)
### _async method_ `resolve_reject()` {#Matcher-resolve-reject} ### _async method_ `resolve_reject()` {#Matcher-resolve-reject}
@ -555,25 +490,21 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context} ### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
- **返回** - **返回**
- untyped - untyped
### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run} ### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -585,13 +516,11 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- untyped - untyped
### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run} ### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -603,7 +532,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- untyped - untyped
## _class_ `MatcherManager()` {#MatcherManager} ## _class_ `MatcherManager()` {#MatcherManager}
@ -625,7 +553,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- KeysView[int] - KeysView[int]
### _method_ `values()` {#MatcherManager-values} ### _method_ `values()` {#MatcherManager-values}
@ -635,7 +562,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- ValuesView[list[type[[Matcher](#Matcher)]]] - ValuesView[list[type[[Matcher](#Matcher)]]]
### _method_ `items()` {#MatcherManager-items} ### _method_ `items()` {#MatcherManager-items}
@ -645,7 +571,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- ItemsView[int, list[type[[Matcher](#Matcher)]]] - ItemsView[int, list[type[[Matcher](#Matcher)]]]
### _method_ `get(key, default=None)` {#MatcherManager-get} ### _method_ `get(key, default=None)` {#MatcherManager-get}
@ -653,35 +578,27 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(key) -> list[type[Matcher]] | None` **1.** `(key) -> list[type[Matcher]] | None`
- **参数** - **参数**
- `key` (int) - `key` (int)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] | None - list[type[[Matcher](#Matcher)]] | None
**2.** `(key, default) -> list[type[Matcher]] | T` **2.** `(key, default) -> list[type[Matcher]] | T`
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (T) - `default` (T)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] | T - list[type[[Matcher](#Matcher)]] | T
### _method_ `pop(key)` {#MatcherManager-pop} ### _method_ `pop(key)` {#MatcherManager-pop}
- **参数** - **参数**
- `key` (int) - `key` (int)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
### _method_ `popitem()` {#MatcherManager-popitem} ### _method_ `popitem()` {#MatcherManager-popitem}
@ -691,7 +608,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- tuple[int, list[type[[Matcher](#Matcher)]]] - tuple[int, list[type[[Matcher](#Matcher)]]]
### _method_ `clear()` {#MatcherManager-clear} ### _method_ `clear()` {#MatcherManager-clear}
@ -701,29 +617,24 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- None - None
### _method_ `update(m, /)` {#MatcherManager-update} ### _method_ `update(m, /)` {#MatcherManager-update}
- **参数** - **参数**
- `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]]) - `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]])
- **返回** - **返回**
- None - None
### _method_ `setdefault(key, default)` {#MatcherManager-setdefault} ### _method_ `setdefault(key, default)` {#MatcherManager-setdefault}
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (list[type[[Matcher](#Matcher)]]) - `default` (list[type[[Matcher](#Matcher)]])
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider} ### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider}
@ -731,11 +642,9 @@ description: nonebot.matcher 模块
- **说明:** 设置事件响应器存储器 - **说明:** 设置事件响应器存储器
- **参数** - **参数**
- `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类 - `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类
- **返回** - **返回**
- None - None
## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider} ## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider}
@ -743,7 +652,6 @@ description: nonebot.matcher 模块
- **说明:** 事件响应器存储器基类 - **说明:** 事件响应器存储器基类
- **参数** - **参数**
- `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器 - `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器
## _var_ `matchers` {#matchers} ## _var_ `matchers` {#matchers}

View File

@ -20,11 +20,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。 装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
- **参数** - **参数**
- `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor)) - `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor))
- **返回** - **返回**
- [T_EventPreProcessor](typing.md#T-EventPreProcessor) - [T_EventPreProcessor](typing.md#T-EventPreProcessor)
## _def_ `event_postprocessor(func)` {#event-postprocessor} ## _def_ `event_postprocessor(func)` {#event-postprocessor}
@ -36,11 +34,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。 装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
- **参数** - **参数**
- `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor)) - `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor))
- **返回** - **返回**
- [T_EventPostProcessor](typing.md#T-EventPostProcessor) - [T_EventPostProcessor](typing.md#T-EventPostProcessor)
## _def_ `run_preprocessor(func)` {#run-preprocessor} ## _def_ `run_preprocessor(func)` {#run-preprocessor}
@ -52,11 +48,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次事件响应器运行前执行。 装饰一个函数,使它在每次事件响应器运行前执行。
- **参数** - **参数**
- `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor)) - `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor))
- **返回** - **返回**
- [T_RunPreProcessor](typing.md#T-RunPreProcessor) - [T_RunPreProcessor](typing.md#T-RunPreProcessor)
## _def_ `run_postprocessor(func)` {#run-postprocessor} ## _def_ `run_postprocessor(func)` {#run-postprocessor}
@ -68,11 +62,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次事件响应器运行后执行。 装饰一个函数,使它在每次事件响应器运行后执行。
- **参数** - **参数**
- `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor)) - `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor))
- **返回** - **返回**
- [T_RunPostProcessor](typing.md#T-RunPostProcessor) - [T_RunPostProcessor](typing.md#T-RunPostProcessor)
## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher} ## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher}
@ -80,7 +72,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- **说明:** 检查并运行事件响应器。 - **说明:** 检查并运行事件响应器。
- **参数** - **参数**
- `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器 - `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
@ -94,7 +85,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- None - None
## _async def_ `handle_event(bot, event)` {#handle-event} ## _async def_ `handle_event(bot, event)` {#handle-event}
@ -102,13 +92,11 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- **说明:** 处理一个事件。调用该函数以实现分发事件。 - **说明:** 处理一个事件。调用该函数以实现分发事件。
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
- **返回** - **返回**
- None - None
- **用法** - **用法**

View File

@ -14,11 +14,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息 - **说明:** Arg 参数消息
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- Any - Any
## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam} ## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam}
@ -33,7 +31,6 @@ description: nonebot.params 模块
留空则会根据参数名称获取。 留空则会根据参数名称获取。
- **参数** - **参数**
- `*args` - `*args`
- `key` (str) - `key` (str)
@ -47,11 +44,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息纯文本 - **说明:** Arg 参数消息纯文本
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- str - str
## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult} ## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult}
@ -59,11 +54,9 @@ description: nonebot.params 模块
- **说明:** `arg` prompt 发送结果 - **说明:** `arg` prompt 发送结果
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- Any - Any
## _def_ `ArgStr(key=None)` {#ArgStr} ## _def_ `ArgStr(key=None)` {#ArgStr}
@ -71,11 +64,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息文本 - **说明:** Arg 参数消息文本
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- str - str
## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam} ## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam}
@ -89,7 +80,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -107,7 +97,6 @@ description: nonebot.params 模块
本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。 本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -125,7 +114,6 @@ description: nonebot.params 模块
本注入应该具有最高优先级,因此应该在其他参数之前检查。 本注入应该具有最高优先级,因此应该在其他参数之前检查。
- **参数** - **参数**
- `*args` - `*args`
- `dependent` ([Dependent](dependencies/index.md#Dependent)[Any]) - `dependent` ([Dependent](dependencies/index.md#Dependent)[Any])
@ -139,7 +127,6 @@ description: nonebot.params 模块
- **说明:** 子依赖装饰器 - **说明:** 子依赖装饰器
- **参数** - **参数**
- `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。 - `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。
- `use_cache` (bool): 是否使用缓存。默认为 `True` - `use_cache` (bool): 是否使用缓存。默认为 `True`
@ -147,7 +134,6 @@ description: nonebot.params 模块
- `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False` - `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False`
- **返回** - **返回**
- Any - Any
- **用法** - **用法**
@ -180,7 +166,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -198,7 +183,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -216,7 +200,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -234,7 +217,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -250,7 +232,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `EventMessage()` {#EventMessage} ## _def_ `EventMessage()` {#EventMessage}
@ -262,7 +243,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `EventPlainText()` {#EventPlainText} ## _def_ `EventPlainText()` {#EventPlainText}
@ -274,7 +254,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `EventToMe()` {#EventToMe} ## _def_ `EventToMe()` {#EventToMe}
@ -286,7 +265,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- bool - bool
## _def_ `Command()` {#Command} ## _def_ `Command()` {#Command}
@ -298,7 +276,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- tuple[str, ...] - tuple[str, ...]
## _def_ `RawCommand()` {#RawCommand} ## _def_ `RawCommand()` {#RawCommand}
@ -310,7 +287,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `CommandArg()` {#CommandArg} ## _def_ `CommandArg()` {#CommandArg}
@ -322,7 +298,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `CommandStart()` {#CommandStart} ## _def_ `CommandStart()` {#CommandStart}
@ -334,7 +309,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `CommandWhitespace()` {#CommandWhitespace} ## _def_ `CommandWhitespace()` {#CommandWhitespace}
@ -346,7 +320,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `ShellCommandArgs()` {#ShellCommandArgs} ## _def_ `ShellCommandArgs()` {#ShellCommandArgs}
@ -358,7 +331,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `ShellCommandArgv()` {#ShellCommandArgv} ## _def_ `ShellCommandArgv()` {#ShellCommandArgv}
@ -370,7 +342,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `RegexMatched()` {#RegexMatched} ## _def_ `RegexMatched()` {#RegexMatched}
@ -382,7 +353,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Match[str] - Match[str]
## _def_ `RegexStr(*groups)` {#RegexStr} ## _def_ `RegexStr(*groups)` {#RegexStr}
@ -392,29 +362,21 @@ description: nonebot.params 模块
- **重载** - **重载**
**1.** `(group, /) -> str` **1.** `(group, /) -> str`
- **参数** - **参数**
- `group` (Literal[0]) - `group` (Literal[0])
- **返回** - **返回**
- str - str
**2.** `(group, /) -> str | Any` **2.** `(group, /) -> str | Any`
- **参数** - **参数**
- `group` (str | int) - `group` (str | int)
- **返回** - **返回**
- str | Any - str | Any
**3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]` **3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]`
- **参数** - **参数**
- `group1` (str | int) - `group1` (str | int)
- `group2` (str | int) - `group2` (str | int)
@ -422,7 +384,6 @@ description: nonebot.params 模块
- `*groups` (str | int) - `*groups` (str | int)
- **返回** - **返回**
- tuple[str | Any, ...] - tuple[str | Any, ...]
## _def_ `RegexGroup()` {#RegexGroup} ## _def_ `RegexGroup()` {#RegexGroup}
@ -434,7 +395,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- tuple[Any, ...] - tuple[Any, ...]
## _def_ `RegexDict()` {#RegexDict} ## _def_ `RegexDict()` {#RegexDict}
@ -446,7 +406,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `Startswith()` {#Startswith} ## _def_ `Startswith()` {#Startswith}
@ -458,7 +417,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Endswith()` {#Endswith} ## _def_ `Endswith()` {#Endswith}
@ -470,7 +428,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Fullmatch()` {#Fullmatch} ## _def_ `Fullmatch()` {#Fullmatch}
@ -482,7 +439,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Keyword()` {#Keyword} ## _def_ `Keyword()` {#Keyword}
@ -494,7 +450,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Received(id=None, default=None)` {#Received} ## _def_ `Received(id=None, default=None)` {#Received}
@ -502,13 +457,11 @@ description: nonebot.params 模块
- **说明:** `receive` 事件参数 - **说明:** `receive` 事件参数
- **参数** - **参数**
- `id` (str | None) - `id` (str | None)
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `LastReceived(default=None)` {#LastReceived} ## _def_ `LastReceived(default=None)` {#LastReceived}
@ -516,11 +469,9 @@ description: nonebot.params 模块
- **说明:** `last_receive` 事件参数 - **说明:** `last_receive` 事件参数
- **参数** - **参数**
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult} ## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult}
@ -528,11 +479,9 @@ description: nonebot.params 模块
- **说明:** `receive` prompt 发送结果 - **说明:** `receive` prompt 发送结果
- **参数** - **参数**
- `id` (str | None) - `id` (str | None)
- **返回** - **返回**
- Any - Any
## _def_ `PausePromptResult()` {#PausePromptResult} ## _def_ `PausePromptResult()` {#PausePromptResult}
@ -544,5 +493,4 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any

View File

@ -22,7 +22,6 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。
- **参数** - **参数**
- `*users` (str) - `*users` (str)
- `perm` (Permission | None): 需要同时满足的权限 - `perm` (Permission | None): 需要同时满足的权限
@ -30,7 +29,6 @@ description: nonebot.permission 模块
- `user`: 会话白名单 - `user`: 会话白名单
- **返回** - **返回**
- untyped - untyped
## _class_ `Permission(*checkers)` {#Permission} ## _class_ `Permission(*checkers)` {#Permission}
@ -42,7 +40,6 @@ description: nonebot.permission 模块
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。 当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
- **参数** - **参数**
- `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker - `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker
- **用法** - **用法**
@ -64,7 +61,6 @@ description: nonebot.permission 模块
- **说明:** 检查是否满足某个权限。 - **说明:** 检查是否满足某个权限。
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
@ -74,7 +70,6 @@ description: nonebot.permission 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool - bool
## _class_ `User(users, perm=None)` {#User} ## _class_ `User(users, perm=None)` {#User}
@ -82,7 +77,6 @@ description: nonebot.permission 模块
- **说明:** 检查当前事件是否属于指定会话。 - **说明:** 检查当前事件是否属于指定会话。
- **参数** - **参数**
- `users` (tuple[str, ...]): 会话 ID 元组 - `users` (tuple[str, ...]): 会话 ID 元组
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
@ -96,13 +90,11 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
- **参数** - **参数**
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
- **返回** - **返回**
- Self - Self
### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission} ### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission}
@ -114,13 +106,11 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
- **参数** - **参数**
- `*users` (str): 会话白名单 - `*users` (str): 会话白名单
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
- **返回** - **返回**
- Self - Self
## _class_ `Message(<auto>)` {#Message} ## _class_ `Message(<auto>)` {#Message}

View File

@ -51,11 +51,9 @@ description: nonebot.plugin 模块
如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名` 如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名`
- **参数** - **参数**
- `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。 - `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name} ## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name}
@ -67,11 +65,9 @@ description: nonebot.plugin 模块
如果提供的模块名为某个插件的子模块,同样会返回该插件。 如果提供的模块名为某个插件的子模块,同样会返回该插件。
- **参数** - **参数**
- `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。 - `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_loaded_plugins()` {#get-loaded-plugins} ## _def_ `get_loaded_plugins()` {#get-loaded-plugins}
@ -83,7 +79,6 @@ description: nonebot.plugin 模块
empty empty
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `get_available_plugin_names()` {#get-available-plugin-names} ## _def_ `get_available_plugin_names()` {#get-available-plugin-names}
@ -95,7 +90,6 @@ description: nonebot.plugin 模块
empty empty
- **返回** - **返回**
- set[str] - set[str]
## _def_ `get_plugin_config(config)` {#get-plugin-config} ## _def_ `get_plugin_config(config)` {#get-plugin-config}
@ -103,9 +97,7 @@ description: nonebot.plugin 模块
- **说明:** 从全局配置获取当前插件需要的配置项。 - **说明:** 从全局配置获取当前插件需要的配置项。
- **参数** - **参数**
- `config` (type[C]) - `config` (type[C])
- **返回** - **返回**
- C - C

View File

@ -14,11 +14,9 @@ description: nonebot.plugin.load 模块
- **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。 - **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。
- **参数** - **参数**
- `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)` - `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)`
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `load_plugins(*plugin_dir)` {#load-plugins} ## _def_ `load_plugins(*plugin_dir)` {#load-plugins}
@ -26,11 +24,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入! - **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `*plugin_dir` (str): 文件夹路径 - `*plugin_dir` (str): 文件夹路径
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins} ## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins}
@ -38,13 +34,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入! - **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `module_path` (Iterable[str]): 指定插件集合 - `module_path` (Iterable[str]): 指定插件集合
- `plugin_dir` (Iterable[str]): 指定文件夹路径集合 - `plugin_dir` (Iterable[str]): 指定文件夹路径集合
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json} ## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json}
@ -52,13 +46,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入! - **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `file_path` (str): 指定 json 文件路径 - `file_path` (str): 指定 json 文件路径
- `encoding` (str): 指定 json 文件编码 - `encoding` (str): 指定 json 文件编码
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
- **用法** - **用法**
@ -79,13 +71,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入! - **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `file_path` (str): 指定 toml 文件路径 - `file_path` (str): 指定 toml 文件路径
- `encoding` (str): 指定 toml 文件编码 - `encoding` (str): 指定 toml 文件编码
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
- **用法** - **用法**
@ -105,11 +95,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入 NoneBot 内置插件。 - **说明:** 导入 NoneBot 内置插件。
- **参数** - **参数**
- `name` (str): 插件名称 - `name` (str): 插件名称
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins} ## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins}
@ -117,11 +105,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入多个 NoneBot 内置插件。 - **说明:** 导入多个 NoneBot 内置插件。
- **参数** - **参数**
- `*plugins` (str): 插件名称列表 - `*plugins` (str): 插件名称列表
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `require(name)` {#require} ## _def_ `require(name)` {#require}
@ -129,15 +115,12 @@ description: nonebot.plugin.load 模块
- **说明:** 声明依赖插件。 - **说明:** 声明依赖插件。
- **参数** - **参数**
- `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。 - `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。
- **返回** - **返回**
- ModuleType - ModuleType
- **异常** - **异常**
- RuntimeError: 插件无法加载 - RuntimeError: 插件无法加载
## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters} ## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters}
@ -149,15 +132,12 @@ description: nonebot.plugin.load 模块
如果传入了多个插件名称,返回值会自动取交集。 如果传入了多个插件名称,返回值会自动取交集。
- **参数** - **参数**
- `*names` (str): 插件名称列表。 - `*names` (str): 插件名称列表。
- **返回** - **返回**
- set[str] | None - set[str] | None
- **异常** - **异常**
- RuntimeError: 插件未加载 - RuntimeError: 插件未加载
- ValueError: 插件缺少元数据 - ValueError: 插件缺少元数据

View File

@ -16,7 +16,6 @@ description: nonebot.plugin.manager 模块
- **说明:** 插件管理器。 - **说明:** 插件管理器。
- **参数** - **参数**
- `plugins` (Iterable[str] | None): 独立插件模块名集合。 - `plugins` (Iterable[str] | None): 独立插件模块名集合。
- `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。 - `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。
@ -54,11 +53,9 @@ description: nonebot.plugin.manager 模块
可以使用完整插件模块名或者插件标识符加载。 可以使用完整插件模块名或者插件标识符加载。
- **参数** - **参数**
- `name` (str): 插件名称或插件标识符。 - `name` (str): 插件名称或插件标识符。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins} ### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins}
@ -70,7 +67,6 @@ description: nonebot.plugin.manager 模块
empty empty
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _class_ `PluginFinder(<auto>)` {#PluginFinder} ## _class_ `PluginFinder(<auto>)` {#PluginFinder}
@ -82,7 +78,6 @@ description: nonebot.plugin.manager 模块
### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec} ### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec}
- **参数** - **参数**
- `fullname` (str) - `fullname` (str)
- `path` (Sequence[str] | None) - `path` (Sequence[str] | None)
@ -90,13 +85,11 @@ description: nonebot.plugin.manager 模块
- `target` (ModuleType | None) - `target` (ModuleType | None)
- **返回** - **返回**
- untyped - untyped
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader} ## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
- **参数** - **参数**
- `manager` (PluginManager) - `manager` (PluginManager)
- `fullname` (str) - `fullname` (str)
@ -106,19 +99,15 @@ description: nonebot.plugin.manager 模块
### _method_ `create_module(spec)` {#PluginLoader-create-module} ### _method_ `create_module(spec)` {#PluginLoader-create-module}
- **参数** - **参数**
- `spec` - `spec`
- **返回** - **返回**
- ModuleType | None - ModuleType | None
### _method_ `exec_module(module)` {#PluginLoader-exec-module} ### _method_ `exec_module(module)` {#PluginLoader-exec-module}
- **参数** - **参数**
- `module` (ModuleType) - `module` (ModuleType)
- **返回** - **返回**
- None - None

View File

@ -80,7 +80,6 @@ description: nonebot.plugin.model 模块
empty empty
- **返回** - **返回**
- set[type[[Adapter](../adapters/index.md#Adapter)]] | None - set[type[[Adapter](../adapters/index.md#Adapter)]] | None
## _class_ `Plugin(<auto>)` {#Plugin} ## _class_ `Plugin(<auto>)` {#Plugin}

View File

@ -14,11 +14,9 @@ description: nonebot.plugin.on 模块
- **说明:** 存储一个事件响应器到插件。 - **说明:** 存储一个事件响应器到插件。
- **参数** - **参数**
- `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器 - `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器
- **返回** - **返回**
- None - None
## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin} ## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin}
@ -30,11 +28,9 @@ description: nonebot.plugin.on 模块
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。 **Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_matcher_module(depth=...)` {#get-matcher-module} ## _def_ `get_matcher_module(depth=...)` {#get-matcher-module}
@ -46,11 +42,9 @@ description: nonebot.plugin.on 模块
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。 **Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- ModuleType | None - ModuleType | None
## _def_ `get_matcher_source(depth=...)` {#get-matcher-source} ## _def_ `get_matcher_source(depth=...)` {#get-matcher-source}
@ -58,11 +52,9 @@ description: nonebot.plugin.on 模块
- **说明:** 获取事件响应器定义所在源码信息。 - **说明:** 获取事件响应器定义所在源码信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- MatcherSource | None - MatcherSource | None
## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on} ## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on}
@ -70,7 +62,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个基础事件响应器,可自定义类型。 - **说明:** 注册一个基础事件响应器,可自定义类型。
- **参数** - **参数**
- `type` (str): 事件响应器类型 - `type` (str): 事件响应器类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -90,7 +81,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent} ## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent}
@ -98,7 +88,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个元事件响应器。 - **说明:** 注册一个元事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -116,7 +105,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message} ## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message}
@ -124,7 +112,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器。 - **说明:** 注册一个消息事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -142,7 +129,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice} ## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice}
@ -150,7 +136,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个通知事件响应器。 - **说明:** 注册一个通知事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -168,7 +153,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request} ## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request}
@ -176,7 +160,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个请求事件响应器。 - **说明:** 注册一个请求事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -194,7 +177,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith} ## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith}
@ -202,7 +184,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头内容 - `msg` (str | tuple[str, ...]): 指定消息开头内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -224,7 +205,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith} ## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith}
@ -232,7 +212,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息结尾内容 - `msg` (str | tuple[str, ...]): 指定消息结尾内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -254,7 +233,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch} ## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch}
@ -262,7 +240,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容 - `msg` (str | tuple[str, ...]): 指定消息全匹配内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -284,7 +261,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword} ## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword}
@ -292,7 +268,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。 - **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
- **参数** - **参数**
- `keywords` (set[str]): 关键词列表 - `keywords` (set[str]): 关键词列表
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -312,7 +287,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command} ## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command}
@ -324,7 +298,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_ 命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -348,7 +321,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command} ## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command}
@ -363,7 +335,6 @@ description: nonebot.plugin.on 模块
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。 通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -387,7 +358,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex} ## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex}
@ -399,7 +369,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_ 命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
- **参数** - **参数**
- `pattern` (str): 正则表达式 - `pattern` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则匹配标志 - `flags` (int | re.RegexFlag): 正则匹配标志
@ -421,7 +390,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type} ## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type}
@ -429,7 +397,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。 - **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
- **参数** - **参数**
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型 - `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -449,13 +416,11 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup} ## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup}
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]) - `cmd` (str | tuple[str, ...])
- `prefix_aliases` (bool) - `prefix_aliases` (bool)
@ -481,7 +446,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值 - **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -505,7 +469,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command} ### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command}
@ -513,7 +476,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值 - **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -537,13 +499,11 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup} ## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup}
- **参数** - **参数**
- `type` (str) - `type` (str)
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None) - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None)
@ -567,7 +527,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个基础事件响应器,可自定义类型。 - **说明:** 注册一个基础事件响应器,可自定义类型。
- **参数** - **参数**
- `type` (str): 事件响应器类型 - `type` (str): 事件响应器类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -587,7 +546,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent} ### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent}
@ -595,7 +553,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个元事件响应器。 - **说明:** 注册一个元事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -613,7 +570,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message} ### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message}
@ -621,7 +577,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器。 - **说明:** 注册一个消息事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -639,7 +594,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice} ### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice}
@ -647,7 +601,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个通知事件响应器。 - **说明:** 注册一个通知事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -665,7 +618,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request} ### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request}
@ -673,7 +625,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个请求事件响应器。 - **说明:** 注册一个请求事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -691,7 +642,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith} ### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith}
@ -699,7 +649,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头内容 - `msg` (str | tuple[str, ...]): 指定消息开头内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -721,7 +670,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith} ### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith}
@ -729,7 +677,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息结尾内容 - `msg` (str | tuple[str, ...]): 指定消息结尾内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -751,7 +698,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch} ### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch}
@ -759,7 +705,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容 - `msg` (str | tuple[str, ...]): 指定消息全匹配内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -781,7 +726,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword} ### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword}
@ -789,7 +733,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。 - **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
- **参数** - **参数**
- `keywords` (set[str]): 关键词列表 - `keywords` (set[str]): 关键词列表
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -809,7 +752,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command} ### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command}
@ -821,7 +763,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_ 命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名 - `aliases` (set[str | tuple[str, ...]] | None): 命令别名
@ -845,7 +786,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command} ### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command}
@ -860,7 +800,6 @@ description: nonebot.plugin.on 模块
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。 通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名 - `aliases` (set[str | tuple[str, ...]] | None): 命令别名
@ -884,7 +823,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex} ### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex}
@ -896,7 +834,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_ 命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
- **参数** - **参数**
- `pattern` (str): 正则表达式 - `pattern` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则匹配标志 - `flags` (int | re.RegexFlag): 正则匹配标志
@ -918,7 +855,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type} ### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type}
@ -926,7 +862,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。 - **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
- **参数** - **参数**
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型 - `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -946,5 +881,4 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]

View File

@ -22,7 +22,6 @@ description: nonebot.rule 模块
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。 当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
- **参数** - **参数**
- `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker - `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker
- **用法** - **用法**
@ -44,7 +43,6 @@ description: nonebot.rule 模块
- **说明:** 检查是否符合所有规则 - **说明:** 检查是否符合所有规则
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
@ -56,7 +54,6 @@ description: nonebot.rule 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool - bool
## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT} ## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT}
@ -78,7 +75,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否以指定字符串开头。 - **说明:** 检查消息纯文本是否以指定字符串开头。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息开头字符串元组 - `msg` (tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -88,13 +84,11 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本开头。 - **说明:** 匹配消息纯文本开头。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组 - `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule} ## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule}
@ -102,7 +96,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否以指定字符串结尾。 - **说明:** 检查消息纯文本是否以指定字符串结尾。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息结尾字符串元组 - `msg` (tuple[str, ...]): 指定消息结尾字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -112,13 +105,11 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本结尾。 - **说明:** 匹配消息纯文本结尾。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组 - `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule} ## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule}
@ -126,7 +117,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否与指定字符串全匹配。 - **说明:** 检查消息纯文本是否与指定字符串全匹配。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息全匹配字符串元组 - `msg` (tuple[str, ...]): 指定消息全匹配字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -136,13 +126,11 @@ description: nonebot.rule 模块
- **说明:** 完全匹配消息。 - **说明:** 完全匹配消息。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组 - `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `KeywordsRule(*keywords)` {#KeywordsRule} ## _class_ `KeywordsRule(*keywords)` {#KeywordsRule}
@ -150,7 +138,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否包含指定关键字。 - **说明:** 检查消息纯文本是否包含指定关键字。
- **参数** - **参数**
- `*keywords` (str): 指定关键字元组 - `*keywords` (str): 指定关键字元组
## _def_ `keyword(*keywords)` {#keyword} ## _def_ `keyword(*keywords)` {#keyword}
@ -158,11 +145,9 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本关键词。 - **说明:** 匹配消息纯文本关键词。
- **参数** - **参数**
- `*keywords` (str): 指定关键字元组 - `*keywords` (str): 指定关键字元组
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule} ## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule}
@ -170,7 +155,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息是否为指定命令。 - **说明:** 检查消息是否为指定命令。
- **参数** - **参数**
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表 - `cmds` (list[tuple[str, ...]]): 指定命令元组列表
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符 - `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
@ -189,13 +173,11 @@ description: nonebot.rule 模块
通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。 通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。
- **参数** - **参数**
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组 - `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符 - `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
- **用法** - **用法**
@ -231,37 +213,28 @@ description: nonebot.rule 模块
- **重载** - **重载**
**1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]` **1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]`
- **参数** - **参数**
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None) - `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
- `namespace` (None) - `namespace` (None)
- **返回** - **返回**
- tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
**2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]` **2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]`
- **参数** - **参数**
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None) - `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
- `namespace` (T) - `namespace` (T)
- **返回** - **返回**
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
**3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]` **3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]`
- **参数** - **参数**
- `namespace` (T) - `namespace` (T)
- **返回** - **返回**
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule} ## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule}
@ -269,7 +242,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息是否为指定 shell 命令。 - **说明:** 检查消息是否为指定 shell 命令。
- **参数** - **参数**
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表 - `cmds` (list[tuple[str, ...]]): 指定命令元组列表
- `parser` (ArgumentParser | None): 可选参数解析器 - `parser` (ArgumentParser | None): 可选参数解析器
@ -298,13 +270,11 @@ description: nonebot.rule 模块
::: :::
- **参数** - **参数**
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组 - `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
- `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象 - `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
- **用法** - **用法**
@ -330,7 +300,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息字符串是否符合指定正则表达式。 - **说明:** 检查消息字符串是否符合指定正则表达式。
- **参数** - **参数**
- `regex` (str): 正则表达式 - `regex` (str): 正则表达式
- `flags` (int): 正则表达式标记 - `flags` (int): 正则表达式标记
@ -346,13 +315,11 @@ description: nonebot.rule 模块
通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。 通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。
- **参数** - **参数**
- `regex` (str): 正则表达式 - `regex` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则表达式标记 - `flags` (int | re.RegexFlag): 正则表达式标记
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
:::tip 提示 :::tip 提示
@ -380,7 +347,6 @@ description: nonebot.rule 模块
empty empty
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `IsTypeRule(*types)` {#IsTypeRule} ## _class_ `IsTypeRule(*types)` {#IsTypeRule}
@ -388,7 +354,6 @@ description: nonebot.rule 模块
- **说明:** 检查事件类型是否为指定类型。 - **说明:** 检查事件类型是否为指定类型。
- **参数** - **参数**
- `*types` (type[[Event](adapters/index.md#Event)]) - `*types` (type[[Event](adapters/index.md#Event)])
## _def_ `is_type(*types)` {#is-type} ## _def_ `is_type(*types)` {#is-type}
@ -396,9 +361,7 @@ description: nonebot.rule 模块
- **说明:** 匹配事件类型。 - **说明:** 匹配事件类型。
- **参数** - **参数**
- `*types` (type[[Event](adapters/index.md#Event)]): 事件类型 - `*types` (type[[Event](adapters/index.md#Event)]): 事件类型
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)

View File

@ -19,31 +19,25 @@ description: nonebot.typing 模块
- **说明:** 标记一个方法为父类 interface 的 implement - **说明:** 标记一个方法为父类 interface 的 implement
- **参数** - **参数**
- `InterfaceClass` (object) - `InterfaceClass` (object)
- **返回** - **返回**
- untyped - untyped
## _def_ `type_has_args(type_)` {#type-has-args} ## _def_ `type_has_args(type_)` {#type-has-args}
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `origin_is_union(origin)` {#origin-is-union} ## _def_ `origin_is_union(origin)` {#origin-is-union}
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `origin_is_literal(origin)` {#origin-is-literal} ## _def_ `origin_is_literal(origin)` {#origin-is-literal}
@ -51,11 +45,9 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 Literal 类型 - **说明:** 判断是否是 Literal 类型
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `all_literal_values(type_)` {#all-literal-values} ## _def_ `all_literal_values(type_)` {#all-literal-values}
@ -63,11 +55,9 @@ description: nonebot.typing 模块
- **说明:** 获取 Literal 类型包含的所有值 - **说明:** 获取 Literal 类型包含的所有值
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- list[Any] - list[Any]
## _def_ `origin_is_annotated(origin)` {#origin-is-annotated} ## _def_ `origin_is_annotated(origin)` {#origin-is-annotated}
@ -75,11 +65,9 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 Annotated 类型 - **说明:** 判断是否是 Annotated 类型
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `is_none_type(type_)` {#is-none-type} ## _def_ `is_none_type(type_)` {#is-none-type}
@ -87,17 +75,14 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 None 类型 - **说明:** 判断是否是 None 类型
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref} ## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref}
- **参数** - **参数**
- `ref` (ForwardRef) - `ref` (ForwardRef)
- `globalns` (dict[str, Any]) - `globalns` (dict[str, Any])
@ -105,7 +90,6 @@ description: nonebot.typing 模块
- `localns` (dict[str, Any]) - `localns` (dict[str, Any])
- **返回** - **返回**
- Any - Any
## _class_ `StateFlag(<auto>)` {#StateFlag} ## _class_ `StateFlag(<auto>)` {#StateFlag}
@ -129,7 +113,6 @@ description: nonebot.typing 模块
Bot 连接建立时钩子函数 Bot 连接建立时钩子函数
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- DefaultParam: 带有默认值的参数 - DefaultParam: 带有默认值的参数
@ -143,7 +126,6 @@ description: nonebot.typing 模块
Bot 连接断开时钩子函数 Bot 连接断开时钩子函数
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- DefaultParam: 带有默认值的参数 - DefaultParam: 带有默认值的参数
@ -169,7 +151,6 @@ description: nonebot.typing 模块
事件预处理函数 EventPreProcessor 类型 事件预处理函数 EventPreProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -185,7 +166,6 @@ description: nonebot.typing 模块
事件后处理函数 EventPostProcessor 类型 事件后处理函数 EventPostProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -201,7 +181,6 @@ description: nonebot.typing 模块
事件响应器运行前预处理函数 RunPreProcessor 类型 事件响应器运行前预处理函数 RunPreProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -218,7 +197,6 @@ description: nonebot.typing 模块
事件响应器运行后后处理函数 RunPostProcessor 类型 事件响应器运行后后处理函数 RunPostProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -236,7 +214,6 @@ description: nonebot.typing 模块
RuleChecker 即判断是否响应事件的处理函数。 RuleChecker 即判断是否响应事件的处理函数。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -252,7 +229,6 @@ description: nonebot.typing 模块
PermissionChecker 即判断事件是否满足权限的处理函数。 PermissionChecker 即判断事件是否满足权限的处理函数。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -273,7 +249,6 @@ description: nonebot.typing 模块
TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message` TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message`
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -290,7 +265,6 @@ description: nonebot.typing 模块
PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。 PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象

View File

@ -18,11 +18,9 @@ description: nonebot.utils 模块
参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color) 参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color)
- **参数** - **参数**
- `s` (str): 需要转义的字符串 - `s` (str): 需要转义的字符串
- **返回** - **返回**
- str - str
## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update} ## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update}
@ -30,13 +28,11 @@ description: nonebot.utils 模块
- **说明:** 深度更新合并字典 - **说明:** 深度更新合并字典
- **参数** - **参数**
- `mapping` (dict[K, Any]) - `mapping` (dict[K, Any])
- `*updating_mappings` (dict[K, Any]) - `*updating_mappings` (dict[K, Any])
- **返回** - **返回**
- dict[K, Any] - dict[K, Any]
## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass} ## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass}
@ -44,13 +40,11 @@ description: nonebot.utils 模块
- **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。 - **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。
- **参数** - **参数**
- `cls` (Any) - `cls` (Any)
- `class_or_tuple` (type[Any] | tuple[type[Any], ...]) - `class_or_tuple` (type[Any] | tuple[type[Any], ...])
- **返回** - **返回**
- bool - bool
## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass} ## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass}
@ -60,7 +54,6 @@ description: nonebot.utils 模块
检查 cls 是否是 class_or_tuple 中的一个类型子类。 检查 cls 是否是 class_or_tuple 中的一个类型子类。
特别的: 特别的:
- 如果 cls 是 `typing.Union``types.UnionType` 类型, - 如果 cls 是 `typing.Union``types.UnionType` 类型,
则会检查其中的所有类型是否是 class_or_tuple 中一个类型的子类或 None。 则会检查其中的所有类型是否是 class_or_tuple 中一个类型的子类或 None。
- 如果 cls 是 `typing.Literal` 类型, - 如果 cls 是 `typing.Literal` 类型,
@ -70,13 +63,11 @@ description: nonebot.utils 模块
是否是 class_or_tuple 中一个类型的子类或 None。 是否是 class_or_tuple 中一个类型的子类或 None。
- **参数** - **参数**
- `cls` (Any) - `cls` (Any)
- `class_or_tuple` (type[Any] | tuple[type[Any], ...]) - `class_or_tuple` (type[Any] | tuple[type[Any], ...])
- **返回** - **返回**
- bool - bool
## _def_ `type_is_complex(type_)` {#type-is-complex} ## _def_ `type_is_complex(type_)` {#type-is-complex}
@ -84,11 +75,9 @@ description: nonebot.utils 模块
- **说明:** 检查 type\_ 是否是复杂类型 - **说明:** 检查 type\_ 是否是复杂类型
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable} ## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable}
@ -96,11 +85,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个 callable 协程函数 - **说明:** 检查 call 是否是一个 callable 协程函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `is_gen_callable(call)` {#is-gen-callable} ## _def_ `is_gen_callable(call)` {#is-gen-callable}
@ -108,11 +95,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个生成器函数 - **说明:** 检查 call 是否是一个生成器函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable} ## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable}
@ -120,11 +105,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个异步生成器函数 - **说明:** 检查 call 是否是一个异步生成器函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `run_sync(call)` {#run-sync} ## _def_ `run_sync(call)` {#run-sync}
@ -132,11 +115,9 @@ description: nonebot.utils 模块
- **说明:** 一个用于包装 sync function 为 async function 的装饰器 - **说明:** 一个用于包装 sync function 为 async function 的装饰器
- **参数** - **参数**
- `call` ((P) -> R): 被装饰的同步函数 - `call` ((P) -> R): 被装饰的同步函数
- **返回** - **返回**
- (P) -> Coroutine[None, None, R] - (P) -> Coroutine[None, None, R]
## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager} ## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager}
@ -144,11 +125,9 @@ description: nonebot.utils 模块
- **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数 - **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数
- **参数** - **参数**
- `cm` (AbstractContextManager[T]) - `cm` (AbstractContextManager[T])
- **返回** - **返回**
- AsyncGenerator[T, None] - AsyncGenerator[T, None]
## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch} ## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch}
@ -158,9 +137,7 @@ description: nonebot.utils 模块
- **重载** - **重载**
**1.** `(coro, exc, return_on_err=None) -> T | None` **1.** `(coro, exc, return_on_err=None) -> T | None`
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]) - `coro` (Coroutine[Any, Any, T])
- `exc` (tuple[type[Exception], ...]) - `exc` (tuple[type[Exception], ...])
@ -168,13 +145,10 @@ description: nonebot.utils 模块
- `return_on_err` (None) - `return_on_err` (None)
- **返回** - **返回**
- T | None - T | None
**2.** `(coro, exc, return_on_err) -> T | R` **2.** `(coro, exc, return_on_err) -> T | R`
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]) - `coro` (Coroutine[Any, Any, T])
- `exc` (tuple[type[Exception], ...]) - `exc` (tuple[type[Exception], ...])
@ -182,11 +156,9 @@ description: nonebot.utils 模块
- `return_on_err` (R) - `return_on_err` (R)
- **返回** - **返回**
- T | R - T | R
- **参数** - **参数**
- `coro`: 要运行的协程 - `coro`: 要运行的协程
- `exc`: 要捕获的异常 - `exc`: 要捕获的异常
@ -202,21 +174,17 @@ description: nonebot.utils 模块
- **说明:** 运行协程并在取消时屏蔽取消异常。 - **说明:** 运行协程并在取消时屏蔽取消异常。
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]): 要运行的协程 - `coro` (Coroutine[Any, Any, T]): 要运行的协程
- **返回** - **返回**
- T: 协程的返回值 - T: 协程的返回值
## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group} ## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group}
- **参数** - **参数**
- `exc_group` (BaseExceptionGroup[E]) - `exc_group` (BaseExceptionGroup[E])
- **返回** - **返回**
- Generator[E, None, None] - Generator[E, None, None]
## _def_ `get_name(obj)` {#get-name} ## _def_ `get_name(obj)` {#get-name}
@ -224,11 +192,9 @@ description: nonebot.utils 模块
- **说明:** 获取对象的名称 - **说明:** 获取对象的名称
- **参数** - **参数**
- `obj` (Any) - `obj` (Any)
- **返回** - **返回**
- str - str
## _def_ `path_to_module_name(path)` {#path-to-module-name} ## _def_ `path_to_module_name(path)` {#path-to-module-name}
@ -236,11 +202,9 @@ description: nonebot.utils 模块
- **说明:** 转换路径为模块名 - **说明:** 转换路径为模块名
- **参数** - **参数**
- `path` (Path) - `path` (Path)
- **返回** - **返回**
- str - str
## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation} ## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation}
@ -248,7 +212,6 @@ description: nonebot.utils 模块
- **说明:** 解析并导入点分表示法的对象 - **说明:** 解析并导入点分表示法的对象
- **参数** - **参数**
- `obj_str` (str) - `obj_str` (str)
- `default_attr` (str) - `default_attr` (str)
@ -256,7 +219,6 @@ description: nonebot.utils 模块
- `default_prefix` (str | None) - `default_prefix` (str | None)
- **返回** - **返回**
- Any - Any
## _class_ `classproperty(func)` {#classproperty} ## _class_ `classproperty(func)` {#classproperty}
@ -264,7 +226,6 @@ description: nonebot.utils 模块
- **说明:** 类属性装饰器 - **说明:** 类属性装饰器
- **参数** - **参数**
- `func` ((Any) -> T) - `func` ((Any) -> T)
## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder} ## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder}
@ -278,11 +239,9 @@ description: nonebot.utils 模块
### _method_ `default(o)` {#DataclassEncoder-default} ### _method_ `default(o)` {#DataclassEncoder-default}
- **参数** - **参数**
- `o` - `o`
- **返回** - **返回**
- untyped - untyped
## _def_ `logger_wrapper(logger_name)` {#logger-wrapper} ## _def_ `logger_wrapper(logger_name)` {#logger-wrapper}
@ -290,15 +249,12 @@ description: nonebot.utils 模块
- **说明:** 用于打印 adapter 的日志。 - **说明:** 用于打印 adapter 的日志。
- **参数** - **参数**
- `logger_name` (str): adapter 的名称 - `logger_name` (str): adapter 的名称
- **返回** - **返回**
- untyped: 日志记录函数 - untyped: 日志记录函数
日志记录函数的参数: 日志记录函数的参数:
- level: 日志等级 - level: 日志等级
- message: 日志信息 - message: 日志信息
- exception: 异常信息 - exception: 异常信息

View File

@ -278,7 +278,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
`Arparma` 有如下属性: `Arparma` 有如下属性:
- 调试类 - 调试类
- matched: 是否匹配成功 - matched: 是否匹配成功
- error_data: 解析失败时剩余的数据 - error_data: 解析失败时剩余的数据
- error_info: 解析失败时的异常内容 - error_info: 解析失败时的异常内容

View File

@ -155,7 +155,6 @@ async def test_example(app: App):
1. `should_call_send` 1. `should_call_send`
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数: 定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
- `event`:回复的目标事件。 - `event`:回复的目标事件。
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。 - `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
- `result`send 的返回值,将会返回给插件。 - `result`send 的返回值,将会返回给插件。
@ -164,7 +163,6 @@ async def test_example(app: App):
2. `should_call_api` 2. `should_call_api`
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数: 定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
- `api`API 名称。 - `api`API 名称。
- `data`:预期的请求数据。 - `data`:预期的请求数据。
- `result`call_api 的返回值,将会返回给插件。 - `result`call_api 的返回值,将会返回给插件。

View File

@ -20,7 +20,6 @@ description: nonebot.adapters 模块
通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。 通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。
- **参数** - **参数**
- `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例 - `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例
- `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数 - `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数
@ -46,7 +45,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _property_ `config` {#Adapter-config} ### _property_ `config` {#Adapter-config}
@ -64,11 +62,9 @@ description: nonebot.adapters 模块
当有新的 [Bot](#Bot) 实例连接建立成功时调用。 当有新的 [Bot](#Bot) 实例连接建立成功时调用。
- **参数** - **参数**
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例 - `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
- **返回** - **返回**
- None - None
### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect} ### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect}
@ -80,11 +76,9 @@ description: nonebot.adapters 模块
当有 [Bot](#Bot) 实例连接断开时调用。 当有 [Bot](#Bot) 实例连接断开时调用。
- **参数** - **参数**
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例 - `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
- **返回** - **返回**
- None - None
### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server} ### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server}
@ -92,11 +86,9 @@ description: nonebot.adapters 模块
- **说明:** 设置一个 HTTP 服务器路由配置 - **说明:** 设置一个 HTTP 服务器路由配置
- **参数** - **参数**
- `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server}
@ -104,11 +96,9 @@ description: nonebot.adapters 模块
- **说明:** 设置一个 WebSocket 服务器路由配置 - **说明:** 设置一个 WebSocket 服务器路由配置
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup))
- **返回** - **返回**
- untyped - untyped
### _async method_ `request(setup)` {#Adapter-request} ### _async method_ `request(setup)` {#Adapter-request}
@ -116,11 +106,9 @@ description: nonebot.adapters 模块
- **说明:** 进行一个 HTTP 客户端请求 - **说明:** 进行一个 HTTP 客户端请求
- **参数** - **参数**
- `setup` ([Request](../drivers/index.md#Request)) - `setup` ([Request](../drivers/index.md#Request))
- **返回** - **返回**
- [Response](../drivers/index.md#Response) - [Response](../drivers/index.md#Response)
### _method_ `websocket(setup)` {#Adapter-websocket} ### _method_ `websocket(setup)` {#Adapter-websocket}
@ -128,21 +116,17 @@ description: nonebot.adapters 模块
- **说明:** 建立一个 WebSocket 客户端连接请求 - **说明:** 建立一个 WebSocket 客户端连接请求
- **参数** - **参数**
- `setup` ([Request](../drivers/index.md#Request)) - `setup` ([Request](../drivers/index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None] - AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None]
### _method_ `on_ready(func)` {#Adapter-on-ready} ### _method_ `on_ready(func)` {#Adapter-on-ready}
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
## _abstract class_ `Bot(adapter, self_id)` {#Bot} ## _abstract class_ `Bot(adapter, self_id)` {#Bot}
@ -154,7 +138,6 @@ description: nonebot.adapters 模块
用于处理上报消息,并提供 API 调用接口。 用于处理上报消息,并提供 API 调用接口。
- **参数** - **参数**
- `adapter` ([Adapter](#Adapter)): 协议适配器实例 - `adapter` ([Adapter](#Adapter)): 协议适配器实例
- `self_id` (str): 机器人 ID - `self_id` (str): 机器人 ID
@ -188,13 +171,11 @@ description: nonebot.adapters 模块
- **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用 - **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
- **参数** - **参数**
- `api` (str): API 名称 - `api` (str): API 名称
- `**data` (Any): API 数据 - `**data` (Any): API 数据
- **返回** - **返回**
- Any - Any
- **用法** - **用法**
@ -209,7 +190,6 @@ description: nonebot.adapters 模块
- **说明:** 调用机器人基础发送消息接口 - **说明:** 调用机器人基础发送消息接口
- **参数** - **参数**
- `event` ([Event](#Event)): 上报事件 - `event` ([Event](#Event)): 上报事件
- `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息 - `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息
@ -217,7 +197,6 @@ description: nonebot.adapters 模块
- `**kwargs` (Any): 任意额外参数 - `**kwargs` (Any): 任意额外参数
- **返回** - **返回**
- Any - Any
### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api} ### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api}
@ -227,17 +206,14 @@ description: nonebot.adapters 模块
调用 api 预处理。 调用 api 预处理。
钩子函数参数: 钩子函数参数:
- bot: 当前 bot 对象 - bot: 当前 bot 对象
- api: 调用的 api 名称 - api: 调用的 api 名称
- data: api 调用的参数字典 - data: api 调用的参数字典
- **参数** - **参数**
- `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook)) - `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook))
- **返回** - **返回**
- [T_CallingAPIHook](../typing.md#T-CallingAPIHook) - [T_CallingAPIHook](../typing.md#T-CallingAPIHook)
### _classmethod_ `on_called_api(func)` {#Bot-on-called-api} ### _classmethod_ `on_called_api(func)` {#Bot-on-called-api}
@ -247,7 +223,6 @@ description: nonebot.adapters 模块
调用 api 后处理。 调用 api 后处理。
钩子函数参数: 钩子函数参数:
- bot: 当前 bot 对象 - bot: 当前 bot 对象
- exception: 调用 api 时发生的错误 - exception: 调用 api 时发生的错误
- api: 调用的 api 名称 - api: 调用的 api 名称
@ -255,11 +230,9 @@ description: nonebot.adapters 模块
- result: api 调用的返回 - result: api 调用的返回
- **参数** - **参数**
- `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook)) - `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook))
- **返回** - **返回**
- [T_CalledAPIHook](../typing.md#T-CalledAPIHook) - [T_CalledAPIHook](../typing.md#T-CalledAPIHook)
## _abstract class_ `Event(<auto>)` {#Event} ## _abstract class_ `Event(<auto>)` {#Event}
@ -279,7 +252,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_event_name()` {#Event-get-event-name} ### _abstract method_ `get_event_name()` {#Event-get-event-name}
@ -291,7 +263,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_event_description()` {#Event-get-event-description} ### _abstract method_ `get_event_description()` {#Event-get-event-description}
@ -303,7 +274,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _method_ `get_log_string()` {#Event-get-log-string} ### _method_ `get_log_string()` {#Event-get-log-string}
@ -320,11 +290,9 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
- **异常** - **异常**
- NoLogException: 希望 NoneBot 隐藏该事件日志 - NoLogException: 希望 NoneBot 隐藏该事件日志
### _abstract method_ `get_user_id()` {#Event-get-user-id} ### _abstract method_ `get_user_id()` {#Event-get-user-id}
@ -336,7 +304,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_session_id()` {#Event-get-session-id} ### _abstract method_ `get_session_id()` {#Event-get-session-id}
@ -348,7 +315,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_message()` {#Event-get-message} ### _abstract method_ `get_message()` {#Event-get-message}
@ -360,7 +326,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- [Message](#Message) - [Message](#Message)
### _method_ `get_plaintext()` {#Event-get-plaintext} ### _method_ `get_plaintext()` {#Event-get-plaintext}
@ -376,7 +341,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `is_tome()` {#Event-is-tome} ### _abstract method_ `is_tome()` {#Event-is-tome}
@ -388,7 +352,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- bool - bool
## _abstract class_ `Message(<auto>)` {#Message} ## _abstract class_ `Message(<auto>)` {#Message}
@ -396,7 +359,6 @@ description: nonebot.adapters 模块
- **说明:** 消息序列 - **说明:** 消息序列
- **参数** - **参数**
- `message`: 消息内容 - `message`: 消息内容
### _classmethod_ `template(format_string)` {#Message-template} ### _classmethod_ `template(format_string)` {#Message-template}
@ -410,11 +372,9 @@ description: nonebot.adapters 模块
可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。 可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。
- **参数** - **参数**
- `format_string` (str | TM): 格式化模板 - `format_string` (str | TM): 格式化模板
- **返回** - **返回**
- [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器 - [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器
### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class} ### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class}
@ -426,7 +386,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- type[TMS] - type[TMS]
### _abstract staticmethod_ `_construct(msg)` {#Message--construct} ### _abstract staticmethod_ `_construct(msg)` {#Message--construct}
@ -434,11 +393,9 @@ description: nonebot.adapters 模块
- **说明:** 构造消息数组 - **说明:** 构造消息数组
- **参数** - **参数**
- `msg` (str) - `msg` (str)
- **返回** - **返回**
- Iterable[TMS] - Iterable[TMS]
### _method_ `__getitem__(args)` {#Message---getitem--} ### _method_ `__getitem__(args)` {#Message---getitem--}
@ -446,53 +403,38 @@ description: nonebot.adapters 模块
- **重载** - **重载**
**1.** `(args) -> Self` **1.** `(args) -> Self`
- **参数** - **参数**
- `args` (str): 消息段类型 - `args` (str): 消息段类型
- **返回** - **返回**
- Self: 所有类型为 `args` 的消息段 - Self: 所有类型为 `args` 的消息段
**2.** `(args) -> TMS` **2.** `(args) -> TMS`
- **参数** - **参数**
- `args` (tuple[str, int]): 消息段类型和索引 - `args` (tuple[str, int]): 消息段类型和索引
- **返回** - **返回**
- TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个 - TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个
**3.** `(args) -> Self` **3.** `(args) -> Self`
- **参数** - **参数**
- `args` (tuple[str, slice]): 消息段类型和切片 - `args` (tuple[str, slice]): 消息段类型和切片
- **返回** - **返回**
- Self: 类型为 `args[0]` 的消息段切片 `args[1]` - Self: 类型为 `args[0]` 的消息段切片 `args[1]`
**4.** `(args) -> TMS` **4.** `(args) -> TMS`
- **参数** - **参数**
- `args` (int): 索引 - `args` (int): 索引
- **返回** - **返回**
- TMS: 第 `args` 个消息段 - TMS: 第 `args` 个消息段
**5.** `(args) -> Self` **5.** `(args) -> Self`
- **参数** - **参数**
- `args` (slice): 切片 - `args` (slice): 切片
- **返回** - **返回**
- Self: 消息切片 `args` - Self: 消息切片 `args`
### _method_ `__contains__(value)` {#Message---contains--} ### _method_ `__contains__(value)` {#Message---contains--}
@ -500,11 +442,9 @@ description: nonebot.adapters 模块
- **说明:** 检查消息段是否存在 - **说明:** 检查消息段是否存在
- **参数** - **参数**
- `value` (TMS | str): 消息段或消息段类型 - `value` (TMS | str): 消息段或消息段类型
- **返回** - **返回**
- bool: 消息内是否存在给定消息段或给定类型的消息段 - bool: 消息内是否存在给定消息段或给定类型的消息段
### _method_ `has(value)` {#Message-has} ### _method_ `has(value)` {#Message-has}
@ -512,11 +452,9 @@ description: nonebot.adapters 模块
- **说明:** 与 [`__contains__`](#Message---contains--) 相同 - **说明:** 与 [`__contains__`](#Message---contains--) 相同
- **参数** - **参数**
- `value` (TMS | str) - `value` (TMS | str)
- **返回** - **返回**
- bool - bool
### _method_ `index(value, *args)` {#Message-index} ### _method_ `index(value, *args)` {#Message-index}
@ -524,7 +462,6 @@ description: nonebot.adapters 模块
- **说明:** 索引消息段 - **说明:** 索引消息段
- **参数** - **参数**
- `value` (TMS | str): 消息段或者消息段类型 - `value` (TMS | str): 消息段或者消息段类型
- `*args` (SupportsIndex) - `*args` (SupportsIndex)
@ -532,11 +469,9 @@ description: nonebot.adapters 模块
- `arg`: start 与 end - `arg`: start 与 end
- **返回** - **返回**
- int: 索引 index - int: 索引 index
- **异常** - **异常**
- ValueError: 消息段不存在 - ValueError: 消息段不存在
### _method_ `get(type_, count=None)` {#Message-get} ### _method_ `get(type_, count=None)` {#Message-get}
@ -544,13 +479,11 @@ description: nonebot.adapters 模块
- **说明:** 获取指定类型的消息段 - **说明:** 获取指定类型的消息段
- **参数** - **参数**
- `type_` (str): 消息段类型 - `type_` (str): 消息段类型
- `count` (int | None): 获取个数 - `count` (int | None): 获取个数
- **返回** - **返回**
- Self: 构建的新消息 - Self: 构建的新消息
### _method_ `count(value)` {#Message-count} ### _method_ `count(value)` {#Message-count}
@ -558,11 +491,9 @@ description: nonebot.adapters 模块
- **说明:** 计算指定消息段的个数 - **说明:** 计算指定消息段的个数
- **参数** - **参数**
- `value` (TMS | str): 消息段或消息段类型 - `value` (TMS | str): 消息段或消息段类型
- **返回** - **返回**
- int: 个数 - int: 个数
### _method_ `only(value)` {#Message-only} ### _method_ `only(value)` {#Message-only}
@ -570,11 +501,9 @@ description: nonebot.adapters 模块
- **说明:** 检查消息中是否仅包含指定消息段 - **说明:** 检查消息中是否仅包含指定消息段
- **参数** - **参数**
- `value` (TMS | str): 指定消息段或消息段类型 - `value` (TMS | str): 指定消息段或消息段类型
- **返回** - **返回**
- bool: 是否仅包含指定消息段 - bool: 是否仅包含指定消息段
### _method_ `append(obj)` {#Message-append} ### _method_ `append(obj)` {#Message-append}
@ -582,11 +511,9 @@ description: nonebot.adapters 模块
- **说明:** 添加一个消息段到消息数组末尾。 - **说明:** 添加一个消息段到消息数组末尾。
- **参数** - **参数**
- `obj` (str | TMS): 要添加的消息段 - `obj` (str | TMS): 要添加的消息段
- **返回** - **返回**
- Self - Self
### _method_ `extend(obj)` {#Message-extend} ### _method_ `extend(obj)` {#Message-extend}
@ -594,11 +521,9 @@ description: nonebot.adapters 模块
- **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。 - **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。
- **参数** - **参数**
- `obj` (Self | Iterable[TMS]): 要添加的消息数组 - `obj` (Self | Iterable[TMS]): 要添加的消息数组
- **返回** - **返回**
- Self - Self
### _method_ `join(iterable)` {#Message-join} ### _method_ `join(iterable)` {#Message-join}
@ -606,11 +531,9 @@ description: nonebot.adapters 模块
- **说明:** 将多个消息连接并将自身作为分割 - **说明:** 将多个消息连接并将自身作为分割
- **参数** - **参数**
- `iterable` (Iterable[TMS | Self]): 要连接的消息 - `iterable` (Iterable[TMS | Self]): 要连接的消息
- **返回** - **返回**
- Self: 连接后的消息 - Self: 连接后的消息
### _method_ `copy()` {#Message-copy} ### _method_ `copy()` {#Message-copy}
@ -622,7 +545,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- Self - Self
### _method_ `include(*types)` {#Message-include} ### _method_ `include(*types)` {#Message-include}
@ -630,11 +552,9 @@ description: nonebot.adapters 模块
- **说明:** 过滤消息 - **说明:** 过滤消息
- **参数** - **参数**
- `*types` (str): 包含的消息段类型 - `*types` (str): 包含的消息段类型
- **返回** - **返回**
- Self: 新构造的消息 - Self: 新构造的消息
### _method_ `exclude(*types)` {#Message-exclude} ### _method_ `exclude(*types)` {#Message-exclude}
@ -642,11 +562,9 @@ description: nonebot.adapters 模块
- **说明:** 过滤消息 - **说明:** 过滤消息
- **参数** - **参数**
- `*types` (str): 不包含的消息段类型 - `*types` (str): 不包含的消息段类型
- **返回** - **返回**
- Self: 新构造的消息 - Self: 新构造的消息
### _method_ `extract_plain_text()` {#Message-extract-plain-text} ### _method_ `extract_plain_text()` {#Message-extract-plain-text}
@ -658,7 +576,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment} ## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment}
@ -690,7 +607,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- type[TM] - type[TM]
### _abstract method_ `__str__()` {#MessageSegment---str--} ### _abstract method_ `__str__()` {#MessageSegment---str--}
@ -702,29 +618,24 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _method_ `__add__(other)` {#MessageSegment---add--} ### _method_ `__add__(other)` {#MessageSegment---add--}
- **参数** - **参数**
- `other` (str | TMS | Iterable[TMS]) - `other` (str | TMS | Iterable[TMS])
- **返回** - **返回**
- TM - TM
### _method_ `get(key, default=None)` {#MessageSegment-get} ### _method_ `get(key, default=None)` {#MessageSegment-get}
- **参数** - **参数**
- `key` (str) - `key` (str)
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- untyped - untyped
### _method_ `keys()` {#MessageSegment-keys} ### _method_ `keys()` {#MessageSegment-keys}
@ -734,7 +645,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `values()` {#MessageSegment-values} ### _method_ `values()` {#MessageSegment-values}
@ -744,7 +654,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `items()` {#MessageSegment-items} ### _method_ `items()` {#MessageSegment-items}
@ -754,17 +663,14 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `join(iterable)` {#MessageSegment-join} ### _method_ `join(iterable)` {#MessageSegment-join}
- **参数** - **参数**
- `iterable` (Iterable[TMS | TM]) - `iterable` (Iterable[TMS | TM])
- **返回** - **返回**
- TM - TM
### _method_ `copy()` {#MessageSegment-copy} ### _method_ `copy()` {#MessageSegment-copy}
@ -774,7 +680,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- Self - Self
### _abstract method_ `is_text()` {#MessageSegment-is-text} ### _abstract method_ `is_text()` {#MessageSegment-is-text}
@ -786,7 +691,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- bool - bool
## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate} ## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate}
@ -794,7 +698,6 @@ description: nonebot.adapters 模块
- **说明:** 消息模板格式化实现类。 - **说明:** 消息模板格式化实现类。
- **参数** - **参数**
- `template` (str | TM): 模板 - `template` (str | TM): 模板
- `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str` - `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str`
@ -804,13 +707,11 @@ description: nonebot.adapters 模块
### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec} ### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec}
- **参数** - **参数**
- `spec` (FormatSpecFunc_T) - `spec` (FormatSpecFunc_T)
- `name` (str | None) - `name` (str | None)
- **返回** - **返回**
- FormatSpecFunc_T - FormatSpecFunc_T
### _method_ `format(*args, **kwargs)` {#MessageTemplate-format} ### _method_ `format(*args, **kwargs)` {#MessageTemplate-format}
@ -818,13 +719,11 @@ description: nonebot.adapters 模块
- **说明:** 根据传入参数和模板生成消息对象 - **说明:** 根据传入参数和模板生成消息对象
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- TF - TF
### _method_ `format_map(mapping)` {#MessageTemplate-format-map} ### _method_ `format_map(mapping)` {#MessageTemplate-format-map}
@ -832,17 +731,14 @@ description: nonebot.adapters 模块
- **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用 - **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用
- **参数** - **参数**
- `mapping` (Mapping[str, Any]) - `mapping` (Mapping[str, Any])
- **返回** - **返回**
- TF - TF
### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat} ### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat}
- **参数** - **参数**
- `format_string` (str) - `format_string` (str)
- `args` (Sequence[Any]) - `args` (Sequence[Any])
@ -850,13 +746,11 @@ description: nonebot.adapters 模块
- `kwargs` (Mapping[str, Any]) - `kwargs` (Mapping[str, Any])
- **返回** - **返回**
- TF - TF
### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field} ### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field}
- **参数** - **参数**
- `field_name` (str) - `field_name` (str)
- `args` (Sequence[Any]) - `args` (Sequence[Any])
@ -864,17 +758,14 @@ description: nonebot.adapters 模块
- `kwargs` (Mapping[str, Any]) - `kwargs` (Mapping[str, Any])
- **返回** - **返回**
- tuple[Any, int | str] - tuple[Any, int | str]
### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field} ### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field}
- **参数** - **参数**
- `value` (Any) - `value` (Any)
- `format_spec` (str) - `format_spec` (str)
- **返回** - **返回**
- Any - Any

View File

@ -36,7 +36,6 @@ description: nonebot.compat 模块
- **说明:** FieldInfo class with extra property for compatibility with pydantic v1 - **说明:** FieldInfo class with extra property for compatibility with pydantic v1
- **参数** - **参数**
- `default` (Any) - `default` (Any)
- `**kwargs` (Any) - `**kwargs` (Any)
@ -82,7 +81,6 @@ description: nonebot.compat 模块
- **说明:** Construct a ModelField from given infos. - **说明:** Construct a ModelField from given infos.
- **参数** - **参数**
- `name` (str) - `name` (str)
- `annotation` (Any) - `annotation` (Any)
@ -90,7 +88,6 @@ description: nonebot.compat 模块
- `field_info` (FieldInfo | None) - `field_info` (FieldInfo | None)
- **返回** - **返回**
- Self - Self
### _method_ `get_default()` {#ModelField-get-default} ### _method_ `get_default()` {#ModelField-get-default}
@ -102,7 +99,6 @@ description: nonebot.compat 模块
empty empty
- **返回** - **返回**
- Any - Any
### _method_ `validate_value(value)` {#ModelField-validate-value} ### _method_ `validate_value(value)` {#ModelField-validate-value}
@ -110,11 +106,9 @@ description: nonebot.compat 模块
- **说明:** Validate the value pass to the field. - **说明:** Validate the value pass to the field.
- **参数** - **参数**
- `value` (Any) - `value` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `extract_field_info(field_info)` {#extract-field-info} ## _def_ `extract_field_info(field_info)` {#extract-field-info}
@ -122,11 +116,9 @@ description: nonebot.compat 模块
- **说明:** Get FieldInfo init kwargs from a FieldInfo instance. - **说明:** Get FieldInfo init kwargs from a FieldInfo instance.
- **参数** - **参数**
- `field_info` (BaseFieldInfo) - `field_info` (BaseFieldInfo)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `model_fields(model)` {#model-fields} ## _def_ `model_fields(model)` {#model-fields}
@ -134,11 +126,9 @@ description: nonebot.compat 模块
- **说明:** Get field list of a model. - **说明:** Get field list of a model.
- **参数** - **参数**
- `model` (type[BaseModel]) - `model` (type[BaseModel])
- **返回** - **返回**
- list[ModelField] - list[ModelField]
## _def_ `model_config(model)` {#model-config} ## _def_ `model_config(model)` {#model-config}
@ -146,17 +136,14 @@ description: nonebot.compat 模块
- **说明:** Get config of a model. - **说明:** Get config of a model.
- **参数** - **参数**
- `model` (type[BaseModel]) - `model` (type[BaseModel])
- **返回** - **返回**
- Any - Any
## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump} ## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump}
- **参数** - **参数**
- `model` (BaseModel) - `model` (BaseModel)
- `include` (set[str] | None) - `include` (set[str] | None)
@ -172,7 +159,6 @@ description: nonebot.compat 模块
- `exclude_none` (bool) - `exclude_none` (bool)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `type_validate_python(type_, data)` {#type-validate-python} ## _def_ `type_validate_python(type_, data)` {#type-validate-python}
@ -180,13 +166,11 @@ description: nonebot.compat 模块
- **说明:** Validate data with given type. - **说明:** Validate data with given type.
- **参数** - **参数**
- `type_` (type[T]) - `type_` (type[T])
- `data` (Any) - `data` (Any)
- **返回** - **返回**
- T - T
## _def_ `type_validate_json(type_, data)` {#type-validate-json} ## _def_ `type_validate_json(type_, data)` {#type-validate-json}
@ -194,13 +178,11 @@ description: nonebot.compat 模块
- **说明:** Validate JSON with given type. - **说明:** Validate JSON with given type.
- **参数** - **参数**
- `type_` (type[T]) - `type_` (type[T])
- `data` (str | bytes) - `data` (str | bytes)
- **返回** - **返回**
- T - T
## _def_ `custom_validation(class_)` {#custom-validation} ## _def_ `custom_validation(class_)` {#custom-validation}
@ -208,9 +190,7 @@ description: nonebot.compat 模块
- **说明:** Use pydantic v1 like validator generator in pydantic v2 - **说明:** Use pydantic v1 like validator generator in pydantic v2
- **参数** - **参数**
- `class_` (type[CVC]) - `class_` (type[CVC])
- **返回** - **返回**
- type[CVC] - type[CVC]

View File

@ -24,7 +24,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。 将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None) - `_env_file` (DOTENV_TYPE | None)
- `_env_file_encoding` (str | None) - `_env_file_encoding` (str | None)
@ -55,7 +54,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
配置方法参考: [配置](https://nonebot.dev/docs/appendices/config) 配置方法参考: [配置](https://nonebot.dev/docs/appendices/config)
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None) - `_env_file` (DOTENV_TYPE | None)
- `_env_file_encoding` (str | None) - `_env_file_encoding` (str | None)

View File

@ -18,7 +18,6 @@ description: nonebot.dependencies 模块
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。 继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -30,7 +29,6 @@ description: nonebot.dependencies 模块
- **说明:** 依赖注入容器 - **说明:** 依赖注入容器
- **参数** - **参数**
- `call`: 依赖注入的可调用对象,可以是任何 Callable 对象 - `call`: 依赖注入的可调用对象,可以是任何 Callable 对象
- `pre_checkers`: 依赖注入解析前的参数检查 - `pre_checkers`: 依赖注入解析前的参数检查
@ -44,31 +42,26 @@ description: nonebot.dependencies 模块
### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params} ### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params}
- **参数** - **参数**
- `call` (\_DependentCallable[R]) - `call` (\_DependentCallable[R])
- `allow_types` (tuple[type[Param], ...]) - `allow_types` (tuple[type[Param], ...])
- **返回** - **返回**
- tuple[[ModelField](../compat.md#ModelField), ...] - tuple[[ModelField](../compat.md#ModelField), ...]
### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless} ### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless}
- **参数** - **参数**
- `parameterless` (tuple[Any, ...]) - `parameterless` (tuple[Any, ...])
- `allow_types` (tuple[type[Param], ...]) - `allow_types` (tuple[type[Param], ...])
- **返回** - **返回**
- tuple[Param, ...] - tuple[Param, ...]
### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse} ### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse}
- **参数** - **参数**
- `call` (\_DependentCallable[R]) - `call` (\_DependentCallable[R])
- `parameterless` (Iterable[Any] | None) - `parameterless` (Iterable[Any] | None)
@ -76,25 +69,20 @@ description: nonebot.dependencies 模块
- `allow_types` (Iterable[type[Param]]) - `allow_types` (Iterable[type[Param]])
- **返回** - **返回**
- Dependent[R] - Dependent[R]
### _async method_ `check(**params)` {#Dependent-check} ### _async method_ `check(**params)` {#Dependent-check}
- **参数** - **参数**
- `**params` (Any) - `**params` (Any)
- **返回** - **返回**
- None - None
### _async method_ `solve(**params)` {#Dependent-solve} ### _async method_ `solve(**params)` {#Dependent-solve}
- **参数** - **参数**
- `**params` (Any) - `**params` (Any)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]

View File

@ -12,11 +12,9 @@ description: nonebot.dependencies.utils 模块
- **说明:** 获取可调用对象签名 - **说明:** 获取可调用对象签名
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- inspect.Signature - inspect.Signature
## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation} ## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation}
@ -24,13 +22,11 @@ description: nonebot.dependencies.utils 模块
- **说明:** 获取参数的类型注解 - **说明:** 获取参数的类型注解
- **参数** - **参数**
- `param` (inspect.Parameter) - `param` (inspect.Parameter)
- `globalns` (dict[str, Any]) - `globalns` (dict[str, Any])
- **返回** - **返回**
- Any - Any
## _def_ `check_field_type(field, value)` {#check-field-type} ## _def_ `check_field_type(field, value)` {#check-field-type}
@ -38,11 +34,9 @@ description: nonebot.dependencies.utils 模块
- **说明:** 检查字段类型是否匹配 - **说明:** 检查字段类型是否匹配
- **参数** - **参数**
- `field` ([ModelField](../compat.md#ModelField)) - `field` ([ModelField](../compat.md#ModelField))
- `value` (Any) - `value` (Any)
- **返回** - **返回**
- Any - Any

View File

@ -22,7 +22,6 @@ pip install nonebot2[aiohttp]
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session} ## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -38,11 +37,9 @@ pip install nonebot2[aiohttp]
### _async method_ `request(setup)` {#Session-request} ### _async method_ `request(setup)` {#Session-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _async method_ `setup()` {#Session-setup} ### _async method_ `setup()` {#Session-setup}
@ -52,7 +49,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close()` {#Session-close} ### _async method_ `close()` {#Session-close}
@ -62,7 +58,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- None - None
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -76,27 +71,22 @@ pip install nonebot2[aiohttp]
### _async method_ `request(setup)` {#Mixin-request} ### _async method_ `request(setup)` {#Mixin-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `websocket(setup)` {#Mixin-websocket} ### _method_ `websocket(setup)` {#Mixin-websocket}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](index.md#WebSocket), None] - AsyncGenerator[[WebSocket](index.md#WebSocket), None]
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session} ### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -110,7 +100,6 @@ pip install nonebot2[aiohttp]
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- Session - Session
## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket} ## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket}
@ -118,7 +107,6 @@ pip install nonebot2[aiohttp]
- **说明:** AIOHTTP Websocket Wrapper - **说明:** AIOHTTP Websocket Wrapper
- **参数** - **参数**
- `request` ([Request](index.md#Request)) - `request` ([Request](index.md#Request))
- `session` (aiohttp.ClientSession) - `session` (aiohttp.ClientSession)
@ -132,19 +120,16 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -154,7 +139,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -164,7 +148,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -174,33 +157,27 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -92,7 +92,6 @@ pip install nonebot2[fastapi]
- **说明:** FastAPI 驱动框架。 - **说明:** FastAPI 驱动框架。
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` (NoneBotConfig) - `config` (NoneBotConfig)
@ -124,21 +123,17 @@ pip install nonebot2[fastapi]
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server} ### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
- **参数** - **参数**
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
- **返回** - **返回**
- None - None
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run} ### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
@ -146,7 +141,6 @@ pip install nonebot2[fastapi]
- **说明:** 使用 `uvicorn` 启动 FastAPI - **说明:** 使用 `uvicorn` 启动 FastAPI
- **参数** - **参数**
- `host` (str | None) - `host` (str | None)
- `port` (int | None) - `port` (int | None)
@ -158,7 +152,6 @@ pip install nonebot2[fastapi]
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket} ## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket}
@ -166,7 +159,6 @@ pip install nonebot2[fastapi]
- **说明:** FastAPI WebSocket Wrapper - **说明:** FastAPI WebSocket Wrapper
- **参数** - **参数**
- `request` (BaseRequest) - `request` (BaseRequest)
- `websocket` ([WebSocket](index.md#WebSocket)) - `websocket` ([WebSocket](index.md#WebSocket))
@ -178,19 +170,16 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close} ### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- None - None
### _async method_ `receive()` {#FastAPIWebSocket-receive} ### _async method_ `receive()` {#FastAPIWebSocket-receive}
@ -200,7 +189,6 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text} ### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text}
@ -210,7 +198,6 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes}
@ -220,25 +207,20 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text} ### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None

View File

@ -22,7 +22,6 @@ pip install nonebot2[httpx]
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session} ## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -38,11 +37,9 @@ pip install nonebot2[httpx]
### _async method_ `request(setup)` {#Session-request} ### _async method_ `request(setup)` {#Session-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _async method_ `setup()` {#Session-setup} ### _async method_ `setup()` {#Session-setup}
@ -52,7 +49,6 @@ pip install nonebot2[httpx]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close()` {#Session-close} ### _async method_ `close()` {#Session-close}
@ -62,7 +58,6 @@ pip install nonebot2[httpx]
empty empty
- **返回** - **返回**
- None - None
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -76,17 +71,14 @@ pip install nonebot2[httpx]
### _async method_ `request(setup)` {#Mixin-request} ### _async method_ `request(setup)` {#Mixin-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session} ### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -100,13 +92,11 @@ pip install nonebot2[httpx]
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- Session - Session
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -40,11 +40,9 @@ description: nonebot.drivers 模块
- **说明:** 设置一个 HTTP 服务器路由配置 - **说明:** 设置一个 HTTP 服务器路由配置
- **参数** - **参数**
- `setup` ([HTTPServerSetup](#HTTPServerSetup)) - `setup` ([HTTPServerSetup](#HTTPServerSetup))
- **返回** - **返回**
- None - None
### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server} ### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server}
@ -52,23 +50,19 @@ description: nonebot.drivers 模块
- **说明:** 设置一个 WebSocket 服务器路由配置 - **说明:** 设置一个 WebSocket 服务器路由配置
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](#WebSocketServerSetup))
- **返回** - **返回**
- None - None
## _class_ `Cookies(cookies=None)` {#Cookies} ## _class_ `Cookies(cookies=None)` {#Cookies}
- **参数** - **参数**
- `cookies` (CookieTypes) - `cookies` (CookieTypes)
### _method_ `set(name, value, domain="", path="/")` {#Cookies-set} ### _method_ `set(name, value, domain="", path="/")` {#Cookies-set}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `value` (str) - `value` (str)
@ -78,13 +72,11 @@ description: nonebot.drivers 模块
- `path` (str) - `path` (str)
- **返回** - **返回**
- None - None
### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get} ### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `default` (str | None) - `default` (str | None)
@ -94,13 +86,11 @@ description: nonebot.drivers 模块
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- str | None - str | None
### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete} ### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `domain` (str | None) - `domain` (str | None)
@ -108,39 +98,32 @@ description: nonebot.drivers 模块
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- None - None
### _method_ `clear(domain=None, path=None)` {#Cookies-clear} ### _method_ `clear(domain=None, path=None)` {#Cookies-clear}
- **参数** - **参数**
- `domain` (str | None) - `domain` (str | None)
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- None - None
### _method_ `update(cookies=None)` {#Cookies-update} ### _method_ `update(cookies=None)` {#Cookies-update}
- **参数** - **参数**
- `cookies` (CookieTypes) - `cookies` (CookieTypes)
- **返回** - **返回**
- None - None
### _method_ `as_header(request)` {#Cookies-as-header} ### _method_ `as_header(request)` {#Cookies-as-header}
- **参数** - **参数**
- `request` (Request) - `request` (Request)
- **返回** - **返回**
- dict[str, str] - dict[str, str]
## _abstract class_ `Driver(env, config)` {#Driver} ## _abstract class_ `Driver(env, config)` {#Driver}
@ -152,7 +135,6 @@ description: nonebot.drivers 模块
驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。 驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。
- **参数** - **参数**
- `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象 - `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象
- `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象 - `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象
@ -180,13 +162,11 @@ description: nonebot.drivers 模块
- **说明:** 注册一个协议适配器 - **说明:** 注册一个协议适配器
- **参数** - **参数**
- `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类 - `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类
- `**kwargs`: 其他传递给适配器的参数 - `**kwargs`: 其他传递给适配器的参数
- **返回** - **返回**
- None - None
### _abstract property_ `type` {#Driver-type} ### _abstract property_ `type` {#Driver-type}
@ -206,13 +186,11 @@ description: nonebot.drivers 模块
- **说明:** 启动驱动框架 - **说明:** 启动驱动框架
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
### _method_ `on_startup(func)` {#Driver-on-startup} ### _method_ `on_startup(func)` {#Driver-on-startup}
@ -220,11 +198,9 @@ description: nonebot.drivers 模块
- **说明:** 注册一个启动时执行的函数 - **说明:** 注册一个启动时执行的函数
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
### _method_ `on_shutdown(func)` {#Driver-on-shutdown} ### _method_ `on_shutdown(func)` {#Driver-on-shutdown}
@ -232,11 +208,9 @@ description: nonebot.drivers 模块
- **说明:** 注册一个停止时执行的函数 - **说明:** 注册一个停止时执行的函数
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect} ### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect}
@ -246,15 +220,12 @@ description: nonebot.drivers 模块
装饰一个函数使他在 bot 连接成功时执行。 装饰一个函数使他在 bot 连接成功时执行。
钩子函数参数: 钩子函数参数:
- bot: 当前连接上的 Bot 对象 - bot: 当前连接上的 Bot 对象
- **参数** - **参数**
- `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook)) - `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook))
- **返回** - **返回**
- [T_BotConnectionHook](../typing.md#T-BotConnectionHook) - [T_BotConnectionHook](../typing.md#T-BotConnectionHook)
### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect} ### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect}
@ -264,15 +235,12 @@ description: nonebot.drivers 模块
装饰一个函数使他在 bot 连接断开时执行。 装饰一个函数使他在 bot 连接断开时执行。
钩子函数参数: 钩子函数参数:
- bot: 当前连接上的 Bot 对象 - bot: 当前连接上的 Bot 对象
- **参数** - **参数**
- `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)) - `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook))
- **返回** - **返回**
- [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook) - [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)
## _var_ `ForwardDriver` {#ForwardDriver} ## _var_ `ForwardDriver` {#ForwardDriver}
@ -306,11 +274,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一个 HTTP 请求 - **说明:** 发送一个 HTTP 请求
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- **返回** - **返回**
- [Response](#Response) - [Response](#Response)
### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session} ### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session}
@ -318,7 +284,6 @@ description: nonebot.drivers 模块
- **说明:** 获取一个 HTTP 会话 - **说明:** 获取一个 HTTP 会话
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -332,7 +297,6 @@ description: nonebot.drivers 模块
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- HTTPClientSession - HTTPClientSession
## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup} ## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup}
@ -350,7 +314,6 @@ description: nonebot.drivers 模块
- **参数** - **参数**
auto auto
- `H10: '1.0'` - `H10: '1.0'`
- `H11: '1.1'` - `H11: '1.1'`
@ -374,7 +337,6 @@ description: nonebot.drivers 模块
## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request} ## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request}
- **参数** - **参数**
- `method` (str | bytes) - `method` (str | bytes)
- `url` (URL | str | RawURL) - `url` (URL | str | RawURL)
@ -402,7 +364,6 @@ description: nonebot.drivers 模块
## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response} ## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response}
- **参数** - **参数**
- `status_code` (int) - `status_code` (int)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -432,7 +393,6 @@ description: nonebot.drivers 模块
## _abstract class_ `WebSocket(*, request)` {#WebSocket} ## _abstract class_ `WebSocket(*, request)` {#WebSocket}
- **参数** - **参数**
- `request` (Request) - `request` (Request)
### _abstract property_ `closed` {#WebSocket-closed} ### _abstract property_ `closed` {#WebSocket-closed}
@ -450,7 +410,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- None - None
### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close}
@ -458,13 +417,11 @@ description: nonebot.drivers 模块
- **说明:** 关闭 WebSocket 连接请求 - **说明:** 关闭 WebSocket 连接请求
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- None - None
### _abstract async method_ `receive()` {#WebSocket-receive} ### _abstract async method_ `receive()` {#WebSocket-receive}
@ -476,7 +433,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _abstract async method_ `receive_text()` {#WebSocket-receive-text} ### _abstract async method_ `receive_text()` {#WebSocket-receive-text}
@ -488,7 +444,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -500,7 +455,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send(data)` {#WebSocket-send} ### _async method_ `send(data)` {#WebSocket-send}
@ -508,11 +462,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket text/bytes 信息 - **说明:** 发送一条 WebSocket text/bytes 信息
- **参数** - **参数**
- `data` (str | bytes) - `data` (str | bytes)
- **返回** - **返回**
- None - None
### _abstract async method_ `send_text(data)` {#WebSocket-send-text} ### _abstract async method_ `send_text(data)` {#WebSocket-send-text}
@ -520,11 +472,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket text 信息 - **说明:** 发送一条 WebSocket text 信息
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes}
@ -532,11 +482,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket binary 信息 - **说明:** 发送一条 WebSocket binary 信息
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin} ## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin}
@ -552,11 +500,9 @@ description: nonebot.drivers 模块
- **说明:** 发起一个 WebSocket 连接 - **说明:** 发起一个 WebSocket 连接
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](#WebSocket), None] - AsyncGenerator[[WebSocket](#WebSocket), None]
## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup} ## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup}
@ -574,19 +520,14 @@ description: nonebot.drivers 模块
- **重载** - **重载**
**1.** `(driver) -> type[D]` **1.** `(driver) -> type[D]`
- **参数** - **参数**
- `driver` (type[D]) - `driver` (type[D])
- **返回** - **返回**
- type[D] - type[D]
**2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]` **2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]`
- **参数** - **参数**
- `driver` (type[D]) - `driver` (type[D])
- `__m` (type[[Mixin](#Mixin)]) - `__m` (type[[Mixin](#Mixin)])
@ -594,5 +535,4 @@ description: nonebot.drivers 模块
- `*mixins` (type[[Mixin](#Mixin)]) - `*mixins` (type[[Mixin](#Mixin)])
- **返回** - **返回**
- type[CombinedDriver] - type[CombinedDriver]

View File

@ -18,7 +18,6 @@ None 驱动适配
- **说明:** None 驱动框架 - **说明:** None 驱动框架
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))
@ -40,13 +39,11 @@ None 驱动适配
- **说明:** 启动 none driver - **说明:** 启动 none driver
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
### _method_ `exit(force=False)` {#Driver-exit} ### _method_ `exit(force=False)` {#Driver-exit}
@ -54,9 +51,7 @@ None 驱动适配
- **说明:** 退出 none driver - **说明:** 退出 none driver
- **参数** - **参数**
- `force` (bool): 强制退出 - `force` (bool): 强制退出
- **返回** - **返回**
- untyped - untyped

View File

@ -68,7 +68,6 @@ pip install nonebot2[quart]
- **说明:** Quart 驱动框架 - **说明:** Quart 驱动框架
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` (NoneBotConfig) - `config` (NoneBotConfig)
@ -100,21 +99,17 @@ pip install nonebot2[quart]
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server} ### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
- **参数** - **参数**
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
- **返回** - **返回**
- None - None
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run} ### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
@ -122,7 +117,6 @@ pip install nonebot2[quart]
- **说明:** 使用 `uvicorn` 启动 Quart - **说明:** 使用 `uvicorn` 启动 Quart
- **参数** - **参数**
- `host` (str | None) - `host` (str | None)
- `port` (int | None) - `port` (int | None)
@ -134,7 +128,6 @@ pip install nonebot2[quart]
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket} ## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket}
@ -142,7 +135,6 @@ pip install nonebot2[quart]
- **说明:** Quart WebSocket Wrapper - **说明:** Quart WebSocket Wrapper
- **参数** - **参数**
- `request` (BaseRequest) - `request` (BaseRequest)
- `websocket_ctx` (WebsocketContext) - `websocket_ctx` (WebsocketContext)
@ -154,19 +146,16 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -176,7 +165,6 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -186,7 +174,6 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -196,25 +183,20 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- untyped - untyped

View File

@ -22,11 +22,9 @@ pip install nonebot2[websockets]
## _def_ `catch_closed(func)` {#catch-closed} ## _def_ `catch_closed(func)` {#catch-closed}
- **参数** - **参数**
- `func` ((P) -> CoroutineType[Any, Any, T]) - `func` ((P) -> CoroutineType[Any, Any, T])
- **返回** - **返回**
- (P) -> CoroutineType[Any, Any, T] - (P) -> CoroutineType[Any, Any, T]
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -40,11 +38,9 @@ pip install nonebot2[websockets]
### _method_ `websocket(setup)` {#Mixin-websocket} ### _method_ `websocket(setup)` {#Mixin-websocket}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](index.md#WebSocket), None] - AsyncGenerator[[WebSocket](index.md#WebSocket), None]
## _class_ `WebSocket(*, request, websocket)` {#WebSocket} ## _class_ `WebSocket(*, request, websocket)` {#WebSocket}
@ -52,7 +48,6 @@ pip install nonebot2[websockets]
- **说明:** Websockets WebSocket Wrapper - **说明:** Websockets WebSocket Wrapper
- **参数** - **参数**
- `request` ([Request](index.md#Request)) - `request` ([Request](index.md#Request))
- `websocket` (WebSocketClientProtocol) - `websocket` (WebSocketClientProtocol)
@ -64,19 +59,16 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -86,7 +78,6 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -96,7 +87,6 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -106,33 +96,27 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -62,7 +62,6 @@ NoneBotException
- **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。 - **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
- **参数** - **参数**
- `reason`: 忽略事件的原因 - `reason`: 忽略事件的原因
## _class_ `SkippedException(<auto>)` {#SkippedException} ## _class_ `SkippedException(<auto>)` {#SkippedException}
@ -101,7 +100,6 @@ NoneBotException
- **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。 - **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。
- **参数** - **参数**
- `result`: 返回的内容 - `result`: 返回的内容
## _class_ `StopPropagation(<auto>)` {#StopPropagation} ## _class_ `StopPropagation(<auto>)` {#StopPropagation}
@ -200,7 +198,6 @@ NoneBotException
- **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。 - **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。
- **参数** - **参数**
- `adapter_name`: 标识 adapter - `adapter_name`: 标识 adapter
## _class_ `NoLogException(<auto>)` {#NoLogException} ## _class_ `NoLogException(<auto>)` {#NoLogException}

View File

@ -60,11 +60,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象 - [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -80,27 +78,20 @@ description: nonebot 模块
- **重载** - **重载**
**1.** `(name) -> Adapter` **1.** `(name) -> Adapter`
- **参数** - **参数**
- `name` (str): 适配器名称 - `name` (str): 适配器名称
- **返回** - **返回**
- [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象 - [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象
**2.** `(name) -> A` **2.** `(name) -> A`
- **参数** - **参数**
- `name` (type[A]): 适配器类型 - `name` (type[A]): 适配器类型
- **返回** - **返回**
- A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象 - A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象
- **异常** - **异常**
- ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册 - ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -121,11 +112,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典 - dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -143,11 +132,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- Any: Server App 对象 - Any: Server App 对象
- **异常** - **异常**
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型 - AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -167,11 +154,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- Any: ASGI 对象 - Any: ASGI 对象
- **异常** - **异常**
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型 - AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -192,15 +177,12 @@ description: nonebot 模块
当不提供时,返回一个 [Bot](adapters/index.md#Bot)。 当不提供时,返回一个 [Bot](adapters/index.md#Bot)。
- **参数** - **参数**
- `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性 - `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性
- **返回** - **返回**
- [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象 - [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象
- **异常** - **异常**
- KeyError: 对应 self_id 的 Bot 不存在 - KeyError: 对应 self_id 的 Bot 不存在
- ValueError: 没有传入 self_id 且没有 Bot 可用 - ValueError: 没有传入 self_id 且没有 Bot 可用
@ -224,13 +206,11 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键 - dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键
[Bot](adapters/index.md#Bot) 对象为值的字典 [Bot](adapters/index.md#Bot) 对象为值的字典
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -250,13 +230,11 @@ description: nonebot 模块
也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。 也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置 - `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置
- `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里 - `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里
- **返回** - **返回**
- None - None
- **用法** - **用法**
@ -270,13 +248,11 @@ description: nonebot 模块
- **说明:** 启动 NoneBot即运行全局 [Driver](drivers/index.md#Driver) 对象。 - **说明:** 启动 NoneBot即运行全局 [Driver](drivers/index.md#Driver) 对象。
- **参数** - **参数**
- `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数 - `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数
- `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数 - `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数
- **返回** - **返回**
- None - None
- **用法** - **用法**

View File

@ -25,7 +25,6 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
NoneBot 日志记录器对象。 NoneBot 日志记录器对象。
默认信息: 默认信息:
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s` - 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
- 等级: `INFO` ,根据 `config.log_level` 配置改变 - 等级: `INFO` ,根据 `config.log_level` 配置改变
- 输出: 输出至 stdout - 输出: 输出至 stdout
@ -47,11 +46,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
### _method_ `emit(record)` {#LoguruHandler-emit} ### _method_ `emit(record)` {#LoguruHandler-emit}
- **参数** - **参数**
- `record` (logging.LogRecord) - `record` (logging.LogRecord)
- **返回** - **返回**
- untyped - untyped
## _def_ `default_filter(record)` {#default-filter} ## _def_ `default_filter(record)` {#default-filter}
@ -59,11 +56,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
- **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。 - **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
- **参数** - **参数**
- `record` (Record) - `record` (Record)
- **返回** - **返回**
- untyped - untyped
## _var_ `default_format` {#default-format} ## _var_ `default_format` {#default-format}

View File

@ -76,7 +76,6 @@ description: nonebot.matcher 模块
- **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_ - **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_
- **参数** - **参数**
- `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意 - `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意
- `rule` ([Rule](rule.md#Rule) | None): 匹配规则 - `rule` ([Rule](rule.md#Rule) | None): 匹配规则
@ -106,7 +105,6 @@ description: nonebot.matcher 模块
- `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数 - `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数
- **返回** - **返回**
- type[Matcher]: 新的事件响应器类 - type[Matcher]: 新的事件响应器类
### _classmethod_ `destroy()` {#Matcher-destroy} ### _classmethod_ `destroy()` {#Matcher-destroy}
@ -118,7 +116,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- None - None
### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm} ### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm}
@ -126,7 +123,6 @@ description: nonebot.matcher 模块
- **说明:** 检查是否满足触发权限 - **说明:** 检查是否满足触发权限
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): 上报事件 - `event` ([Event](adapters/index.md#Event)): 上报事件
@ -136,7 +132,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool: 是否满足权限 - bool: 是否满足权限
### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule} ### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule}
@ -144,7 +139,6 @@ description: nonebot.matcher 模块
- **说明:** 检查是否满足匹配规则 - **说明:** 检查是否满足匹配规则
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): 上报事件 - `event` ([Event](adapters/index.md#Event)): 上报事件
@ -156,7 +150,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool: 是否满足匹配规则 - bool: 是否满足匹配规则
### _classmethod_ `type_updater(func)` {#Matcher-type-updater} ### _classmethod_ `type_updater(func)` {#Matcher-type-updater}
@ -164,11 +157,9 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数 - **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数
- **参数** - **参数**
- `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数 - `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数
- **返回** - **返回**
- [T_TypeUpdater](typing.md#T-TypeUpdater) - [T_TypeUpdater](typing.md#T-TypeUpdater)
### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater} ### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater}
@ -176,23 +167,19 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数 - **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数
- **参数** - **参数**
- `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数 - `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数
- **返回** - **返回**
- [T_PermissionUpdater](typing.md#T-PermissionUpdater) - [T_PermissionUpdater](typing.md#T-PermissionUpdater)
### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler} ### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler}
- **参数** - **参数**
- `handler` ([T_Handler](typing.md#T-Handler)) - `handler` ([T_Handler](typing.md#T-Handler))
- `parameterless` (Iterable[Any] | None) - `parameterless` (Iterable[Any] | None)
- **返回** - **返回**
- [Dependent](dependencies/index.md#Dependent)[Any] - [Dependent](dependencies/index.md#Dependent)[Any]
### _classmethod_ `handle(parameterless=None)` {#Matcher-handle} ### _classmethod_ `handle(parameterless=None)` {#Matcher-handle}
@ -200,11 +187,9 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数 - **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数
- **参数** - **参数**
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive} ### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive}
@ -212,13 +197,11 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数 - **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
- **参数** - **参数**
- `id` (str): 消息 ID - `id` (str): 消息 ID
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got} ### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got}
@ -231,7 +214,6 @@ description: nonebot.matcher 模块
如果 `key` 已存在则直接继续运行 如果 `key` 已存在则直接继续运行
- **参数** - **参数**
- `key` (str): 参数名 - `key` (str): 参数名
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息
@ -239,7 +221,6 @@ description: nonebot.matcher 模块
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `send(message, **kwargs)` {#Matcher-send} ### _classmethod_ `send(message, **kwargs)` {#Matcher-send}
@ -247,13 +228,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户 - **说明:** 发送一条消息给当前交互用户
- **参数** - **参数**
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容 - `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容
- `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- Any - Any
### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish} ### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish}
@ -261,13 +240,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户并结束当前事件响应器 - **说明:** 发送一条消息给当前交互用户并结束当前事件响应器
- **参数** - **参数**
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause} ### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause}
@ -275,13 +252,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数 - **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
- **参数** - **参数**
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject} ### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject}
@ -289,13 +264,11 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数 - **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
- **参数** - **参数**
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg} ### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg}
@ -303,7 +276,6 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数 - **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数
- **参数** - **参数**
- `key` (str): 参数名 - `key` (str): 参数名
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
@ -311,7 +283,6 @@ description: nonebot.matcher 模块
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive} ### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive}
@ -319,7 +290,6 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数 - **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
- **参数** - **参数**
- `id` (str): 消息 id - `id` (str): 消息 id
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
@ -327,7 +297,6 @@ description: nonebot.matcher 模块
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `skip()` {#Matcher-skip} ### _classmethod_ `skip()` {#Matcher-skip}
@ -343,7 +312,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- NoReturn - NoReturn
### _method_ `get_receive(id, default=None)` {#Matcher-get-receive} ### _method_ `get_receive(id, default=None)` {#Matcher-get-receive}
@ -357,25 +325,19 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(id) -> Event | None` **1.** `(id) -> Event | None`
- **参数** - **参数**
- `id` (str) - `id` (str)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | None - [Event](adapters/index.md#Event) | None
**2.** `(id, default) -> Event | T` **2.** `(id, default) -> Event | T`
- **参数** - **参数**
- `id` (str) - `id` (str)
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | T - [Event](adapters/index.md#Event) | T
### _method_ `set_receive(id, event)` {#Matcher-set-receive} ### _method_ `set_receive(id, event)` {#Matcher-set-receive}
@ -383,13 +345,11 @@ description: nonebot.matcher 模块
- **说明:** 设置一个 `receive` 事件 - **说明:** 设置一个 `receive` 事件
- **参数** - **参数**
- `id` (str) - `id` (str)
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
- **返回** - **返回**
- None - None
### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive} ### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive}
@ -403,23 +363,18 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `() -> Event | None` **1.** `() -> Event | None`
- **参数** - **参数**
empty empty
- **返回** - **返回**
- [Event](adapters/index.md#Event) | None - [Event](adapters/index.md#Event) | None
**2.** `(default) -> Event | T` **2.** `(default) -> Event | T`
- **参数** - **参数**
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | T - [Event](adapters/index.md#Event) | T
### _method_ `get_arg(key, default=None)` {#Matcher-get-arg} ### _method_ `get_arg(key, default=None)` {#Matcher-get-arg}
@ -433,25 +388,19 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(key) -> Message | None` **1.** `(key) -> Message | None`
- **参数** - **参数**
- `key` (str) - `key` (str)
- **返回** - **返回**
- [Message](adapters/index.md#Message) | None - [Message](adapters/index.md#Message) | None
**2.** `(key, default) -> Message | T` **2.** `(key, default) -> Message | T`
- **参数** - **参数**
- `key` (str) - `key` (str)
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Message](adapters/index.md#Message) | T - [Message](adapters/index.md#Message) | T
### _method_ `set_arg(key, message)` {#Matcher-set-arg} ### _method_ `set_arg(key, message)` {#Matcher-set-arg}
@ -459,25 +408,21 @@ description: nonebot.matcher 模块
- **说明:** 设置一个 `got` 消息 - **说明:** 设置一个 `got` 消息
- **参数** - **参数**
- `key` (str) - `key` (str)
- `message` ([Message](adapters/index.md#Message)) - `message` ([Message](adapters/index.md#Message))
- **返回** - **返回**
- None - None
### _method_ `set_target(target, cache=True)` {#Matcher-set-target} ### _method_ `set_target(target, cache=True)` {#Matcher-set-target}
- **参数** - **参数**
- `target` (str) - `target` (str)
- `cache` (bool) - `cache` (bool)
- **返回** - **返回**
- None - None
### _method_ `get_target(default=None)` {#Matcher-get-target} ### _method_ `get_target(default=None)` {#Matcher-get-target}
@ -485,23 +430,18 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `() -> str | None` **1.** `() -> str | None`
- **参数** - **参数**
empty empty
- **返回** - **返回**
- str | None - str | None
**2.** `(default) -> str | T` **2.** `(default) -> str | T`
- **参数** - **参数**
- `default` (T) - `default` (T)
- **返回** - **返回**
- str | T - str | T
### _method_ `stop_propagation()` {#Matcher-stop-propagation} ### _method_ `stop_propagation()` {#Matcher-stop-propagation}
@ -513,13 +453,11 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type} ### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -529,13 +467,11 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- str - str
### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission} ### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -545,7 +481,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- [Permission](permission.md#Permission) - [Permission](permission.md#Permission)
### _async method_ `resolve_reject()` {#Matcher-resolve-reject} ### _async method_ `resolve_reject()` {#Matcher-resolve-reject}
@ -555,25 +490,21 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context} ### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
- **返回** - **返回**
- untyped - untyped
### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run} ### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -585,13 +516,11 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- untyped - untyped
### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run} ### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -603,7 +532,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- untyped - untyped
## _class_ `MatcherManager()` {#MatcherManager} ## _class_ `MatcherManager()` {#MatcherManager}
@ -625,7 +553,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- KeysView[int] - KeysView[int]
### _method_ `values()` {#MatcherManager-values} ### _method_ `values()` {#MatcherManager-values}
@ -635,7 +562,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- ValuesView[list[type[[Matcher](#Matcher)]]] - ValuesView[list[type[[Matcher](#Matcher)]]]
### _method_ `items()` {#MatcherManager-items} ### _method_ `items()` {#MatcherManager-items}
@ -645,7 +571,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- ItemsView[int, list[type[[Matcher](#Matcher)]]] - ItemsView[int, list[type[[Matcher](#Matcher)]]]
### _method_ `get(key, default=None)` {#MatcherManager-get} ### _method_ `get(key, default=None)` {#MatcherManager-get}
@ -653,35 +578,27 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(key) -> list[type[Matcher]] | None` **1.** `(key) -> list[type[Matcher]] | None`
- **参数** - **参数**
- `key` (int) - `key` (int)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] | None - list[type[[Matcher](#Matcher)]] | None
**2.** `(key, default) -> list[type[Matcher]] | T` **2.** `(key, default) -> list[type[Matcher]] | T`
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (T) - `default` (T)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] | T - list[type[[Matcher](#Matcher)]] | T
### _method_ `pop(key)` {#MatcherManager-pop} ### _method_ `pop(key)` {#MatcherManager-pop}
- **参数** - **参数**
- `key` (int) - `key` (int)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
### _method_ `popitem()` {#MatcherManager-popitem} ### _method_ `popitem()` {#MatcherManager-popitem}
@ -691,7 +608,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- tuple[int, list[type[[Matcher](#Matcher)]]] - tuple[int, list[type[[Matcher](#Matcher)]]]
### _method_ `clear()` {#MatcherManager-clear} ### _method_ `clear()` {#MatcherManager-clear}
@ -701,29 +617,24 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- None - None
### _method_ `update(m, /)` {#MatcherManager-update} ### _method_ `update(m, /)` {#MatcherManager-update}
- **参数** - **参数**
- `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]]) - `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]])
- **返回** - **返回**
- None - None
### _method_ `setdefault(key, default)` {#MatcherManager-setdefault} ### _method_ `setdefault(key, default)` {#MatcherManager-setdefault}
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (list[type[[Matcher](#Matcher)]]) - `default` (list[type[[Matcher](#Matcher)]])
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider} ### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider}
@ -731,11 +642,9 @@ description: nonebot.matcher 模块
- **说明:** 设置事件响应器存储器 - **说明:** 设置事件响应器存储器
- **参数** - **参数**
- `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类 - `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类
- **返回** - **返回**
- None - None
## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider} ## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider}
@ -743,7 +652,6 @@ description: nonebot.matcher 模块
- **说明:** 事件响应器存储器基类 - **说明:** 事件响应器存储器基类
- **参数** - **参数**
- `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器 - `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器
## _var_ `matchers` {#matchers} ## _var_ `matchers` {#matchers}

View File

@ -20,11 +20,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。 装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
- **参数** - **参数**
- `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor)) - `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor))
- **返回** - **返回**
- [T_EventPreProcessor](typing.md#T-EventPreProcessor) - [T_EventPreProcessor](typing.md#T-EventPreProcessor)
## _def_ `event_postprocessor(func)` {#event-postprocessor} ## _def_ `event_postprocessor(func)` {#event-postprocessor}
@ -36,11 +34,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。 装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
- **参数** - **参数**
- `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor)) - `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor))
- **返回** - **返回**
- [T_EventPostProcessor](typing.md#T-EventPostProcessor) - [T_EventPostProcessor](typing.md#T-EventPostProcessor)
## _def_ `run_preprocessor(func)` {#run-preprocessor} ## _def_ `run_preprocessor(func)` {#run-preprocessor}
@ -52,11 +48,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次事件响应器运行前执行。 装饰一个函数,使它在每次事件响应器运行前执行。
- **参数** - **参数**
- `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor)) - `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor))
- **返回** - **返回**
- [T_RunPreProcessor](typing.md#T-RunPreProcessor) - [T_RunPreProcessor](typing.md#T-RunPreProcessor)
## _def_ `run_postprocessor(func)` {#run-postprocessor} ## _def_ `run_postprocessor(func)` {#run-postprocessor}
@ -68,11 +62,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次事件响应器运行后执行。 装饰一个函数,使它在每次事件响应器运行后执行。
- **参数** - **参数**
- `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor)) - `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor))
- **返回** - **返回**
- [T_RunPostProcessor](typing.md#T-RunPostProcessor) - [T_RunPostProcessor](typing.md#T-RunPostProcessor)
## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher} ## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher}
@ -80,7 +72,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- **说明:** 检查并运行事件响应器。 - **说明:** 检查并运行事件响应器。
- **参数** - **参数**
- `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器 - `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
@ -94,7 +85,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- None - None
## _async def_ `handle_event(bot, event)` {#handle-event} ## _async def_ `handle_event(bot, event)` {#handle-event}
@ -102,13 +92,11 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- **说明:** 处理一个事件。调用该函数以实现分发事件。 - **说明:** 处理一个事件。调用该函数以实现分发事件。
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
- **返回** - **返回**
- None - None
- **用法** - **用法**

View File

@ -14,11 +14,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息 - **说明:** Arg 参数消息
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- Any - Any
## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam} ## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam}
@ -33,7 +31,6 @@ description: nonebot.params 模块
留空则会根据参数名称获取。 留空则会根据参数名称获取。
- **参数** - **参数**
- `*args` - `*args`
- `key` (str) - `key` (str)
@ -47,11 +44,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息纯文本 - **说明:** Arg 参数消息纯文本
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- str - str
## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult} ## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult}
@ -59,11 +54,9 @@ description: nonebot.params 模块
- **说明:** `arg` prompt 发送结果 - **说明:** `arg` prompt 发送结果
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- Any - Any
## _def_ `ArgStr(key=None)` {#ArgStr} ## _def_ `ArgStr(key=None)` {#ArgStr}
@ -71,11 +64,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息文本 - **说明:** Arg 参数消息文本
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- str - str
## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam} ## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam}
@ -89,7 +80,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -107,7 +97,6 @@ description: nonebot.params 模块
本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。 本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -125,7 +114,6 @@ description: nonebot.params 模块
本注入应该具有最高优先级,因此应该在其他参数之前检查。 本注入应该具有最高优先级,因此应该在其他参数之前检查。
- **参数** - **参数**
- `*args` - `*args`
- `dependent` ([Dependent](dependencies/index.md#Dependent)[Any]) - `dependent` ([Dependent](dependencies/index.md#Dependent)[Any])
@ -139,7 +127,6 @@ description: nonebot.params 模块
- **说明:** 子依赖装饰器 - **说明:** 子依赖装饰器
- **参数** - **参数**
- `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。 - `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。
- `use_cache` (bool): 是否使用缓存。默认为 `True` - `use_cache` (bool): 是否使用缓存。默认为 `True`
@ -147,7 +134,6 @@ description: nonebot.params 模块
- `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False` - `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False`
- **返回** - **返回**
- Any - Any
- **用法** - **用法**
@ -180,7 +166,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -198,7 +183,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -216,7 +200,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -234,7 +217,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -250,7 +232,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `EventMessage()` {#EventMessage} ## _def_ `EventMessage()` {#EventMessage}
@ -262,7 +243,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `EventPlainText()` {#EventPlainText} ## _def_ `EventPlainText()` {#EventPlainText}
@ -274,7 +254,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `EventToMe()` {#EventToMe} ## _def_ `EventToMe()` {#EventToMe}
@ -286,7 +265,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- bool - bool
## _def_ `Command()` {#Command} ## _def_ `Command()` {#Command}
@ -298,7 +276,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- tuple[str, ...] - tuple[str, ...]
## _def_ `RawCommand()` {#RawCommand} ## _def_ `RawCommand()` {#RawCommand}
@ -310,7 +287,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `CommandArg()` {#CommandArg} ## _def_ `CommandArg()` {#CommandArg}
@ -322,7 +298,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `CommandStart()` {#CommandStart} ## _def_ `CommandStart()` {#CommandStart}
@ -334,7 +309,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `CommandWhitespace()` {#CommandWhitespace} ## _def_ `CommandWhitespace()` {#CommandWhitespace}
@ -346,7 +320,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `ShellCommandArgs()` {#ShellCommandArgs} ## _def_ `ShellCommandArgs()` {#ShellCommandArgs}
@ -358,7 +331,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `ShellCommandArgv()` {#ShellCommandArgv} ## _def_ `ShellCommandArgv()` {#ShellCommandArgv}
@ -370,7 +342,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `RegexMatched()` {#RegexMatched} ## _def_ `RegexMatched()` {#RegexMatched}
@ -382,7 +353,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Match[str] - Match[str]
## _def_ `RegexStr(*groups)` {#RegexStr} ## _def_ `RegexStr(*groups)` {#RegexStr}
@ -392,29 +362,21 @@ description: nonebot.params 模块
- **重载** - **重载**
**1.** `(group, /) -> str` **1.** `(group, /) -> str`
- **参数** - **参数**
- `group` (Literal[0]) - `group` (Literal[0])
- **返回** - **返回**
- str - str
**2.** `(group, /) -> str | Any` **2.** `(group, /) -> str | Any`
- **参数** - **参数**
- `group` (str | int) - `group` (str | int)
- **返回** - **返回**
- str | Any - str | Any
**3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]` **3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]`
- **参数** - **参数**
- `group1` (str | int) - `group1` (str | int)
- `group2` (str | int) - `group2` (str | int)
@ -422,7 +384,6 @@ description: nonebot.params 模块
- `*groups` (str | int) - `*groups` (str | int)
- **返回** - **返回**
- tuple[str | Any, ...] - tuple[str | Any, ...]
## _def_ `RegexGroup()` {#RegexGroup} ## _def_ `RegexGroup()` {#RegexGroup}
@ -434,7 +395,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- tuple[Any, ...] - tuple[Any, ...]
## _def_ `RegexDict()` {#RegexDict} ## _def_ `RegexDict()` {#RegexDict}
@ -446,7 +406,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `Startswith()` {#Startswith} ## _def_ `Startswith()` {#Startswith}
@ -458,7 +417,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Endswith()` {#Endswith} ## _def_ `Endswith()` {#Endswith}
@ -470,7 +428,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Fullmatch()` {#Fullmatch} ## _def_ `Fullmatch()` {#Fullmatch}
@ -482,7 +439,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Keyword()` {#Keyword} ## _def_ `Keyword()` {#Keyword}
@ -494,7 +450,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Received(id=None, default=None)` {#Received} ## _def_ `Received(id=None, default=None)` {#Received}
@ -502,13 +457,11 @@ description: nonebot.params 模块
- **说明:** `receive` 事件参数 - **说明:** `receive` 事件参数
- **参数** - **参数**
- `id` (str | None) - `id` (str | None)
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `LastReceived(default=None)` {#LastReceived} ## _def_ `LastReceived(default=None)` {#LastReceived}
@ -516,11 +469,9 @@ description: nonebot.params 模块
- **说明:** `last_receive` 事件参数 - **说明:** `last_receive` 事件参数
- **参数** - **参数**
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult} ## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult}
@ -528,11 +479,9 @@ description: nonebot.params 模块
- **说明:** `receive` prompt 发送结果 - **说明:** `receive` prompt 发送结果
- **参数** - **参数**
- `id` (str | None) - `id` (str | None)
- **返回** - **返回**
- Any - Any
## _def_ `PausePromptResult()` {#PausePromptResult} ## _def_ `PausePromptResult()` {#PausePromptResult}
@ -544,5 +493,4 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any

View File

@ -22,7 +22,6 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。
- **参数** - **参数**
- `*users` (str) - `*users` (str)
- `perm` (Permission | None): 需要同时满足的权限 - `perm` (Permission | None): 需要同时满足的权限
@ -30,7 +29,6 @@ description: nonebot.permission 模块
- `user`: 会话白名单 - `user`: 会话白名单
- **返回** - **返回**
- untyped - untyped
## _class_ `Permission(*checkers)` {#Permission} ## _class_ `Permission(*checkers)` {#Permission}
@ -42,7 +40,6 @@ description: nonebot.permission 模块
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。 当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
- **参数** - **参数**
- `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker - `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker
- **用法** - **用法**
@ -64,7 +61,6 @@ description: nonebot.permission 模块
- **说明:** 检查是否满足某个权限。 - **说明:** 检查是否满足某个权限。
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
@ -74,7 +70,6 @@ description: nonebot.permission 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool - bool
## _class_ `User(users, perm=None)` {#User} ## _class_ `User(users, perm=None)` {#User}
@ -82,7 +77,6 @@ description: nonebot.permission 模块
- **说明:** 检查当前事件是否属于指定会话。 - **说明:** 检查当前事件是否属于指定会话。
- **参数** - **参数**
- `users` (tuple[str, ...]): 会话 ID 元组 - `users` (tuple[str, ...]): 会话 ID 元组
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
@ -96,13 +90,11 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
- **参数** - **参数**
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
- **返回** - **返回**
- Self - Self
### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission} ### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission}
@ -114,13 +106,11 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
- **参数** - **参数**
- `*users` (str): 会话白名单 - `*users` (str): 会话白名单
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
- **返回** - **返回**
- Self - Self
## _class_ `Message(<auto>)` {#Message} ## _class_ `Message(<auto>)` {#Message}

View File

@ -51,11 +51,9 @@ description: nonebot.plugin 模块
如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名` 如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名`
- **参数** - **参数**
- `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。 - `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name} ## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name}
@ -67,11 +65,9 @@ description: nonebot.plugin 模块
如果提供的模块名为某个插件的子模块,同样会返回该插件。 如果提供的模块名为某个插件的子模块,同样会返回该插件。
- **参数** - **参数**
- `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。 - `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_loaded_plugins()` {#get-loaded-plugins} ## _def_ `get_loaded_plugins()` {#get-loaded-plugins}
@ -83,7 +79,6 @@ description: nonebot.plugin 模块
empty empty
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `get_available_plugin_names()` {#get-available-plugin-names} ## _def_ `get_available_plugin_names()` {#get-available-plugin-names}
@ -95,7 +90,6 @@ description: nonebot.plugin 模块
empty empty
- **返回** - **返回**
- set[str] - set[str]
## _def_ `get_plugin_config(config)` {#get-plugin-config} ## _def_ `get_plugin_config(config)` {#get-plugin-config}
@ -103,9 +97,7 @@ description: nonebot.plugin 模块
- **说明:** 从全局配置获取当前插件需要的配置项。 - **说明:** 从全局配置获取当前插件需要的配置项。
- **参数** - **参数**
- `config` (type[C]) - `config` (type[C])
- **返回** - **返回**
- C - C

View File

@ -14,11 +14,9 @@ description: nonebot.plugin.load 模块
- **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。 - **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。
- **参数** - **参数**
- `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)` - `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)`
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `load_plugins(*plugin_dir)` {#load-plugins} ## _def_ `load_plugins(*plugin_dir)` {#load-plugins}
@ -26,11 +24,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入! - **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `*plugin_dir` (str): 文件夹路径 - `*plugin_dir` (str): 文件夹路径
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins} ## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins}
@ -38,13 +34,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入! - **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `module_path` (Iterable[str]): 指定插件集合 - `module_path` (Iterable[str]): 指定插件集合
- `plugin_dir` (Iterable[str]): 指定文件夹路径集合 - `plugin_dir` (Iterable[str]): 指定文件夹路径集合
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json} ## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json}
@ -52,13 +46,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入! - **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `file_path` (str): 指定 json 文件路径 - `file_path` (str): 指定 json 文件路径
- `encoding` (str): 指定 json 文件编码 - `encoding` (str): 指定 json 文件编码
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
- **用法** - **用法**
@ -79,13 +71,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入! - **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `file_path` (str): 指定 toml 文件路径 - `file_path` (str): 指定 toml 文件路径
- `encoding` (str): 指定 toml 文件编码 - `encoding` (str): 指定 toml 文件编码
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
- **用法** - **用法**
@ -105,11 +95,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入 NoneBot 内置插件。 - **说明:** 导入 NoneBot 内置插件。
- **参数** - **参数**
- `name` (str): 插件名称 - `name` (str): 插件名称
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins} ## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins}
@ -117,11 +105,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入多个 NoneBot 内置插件。 - **说明:** 导入多个 NoneBot 内置插件。
- **参数** - **参数**
- `*plugins` (str): 插件名称列表 - `*plugins` (str): 插件名称列表
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `require(name)` {#require} ## _def_ `require(name)` {#require}
@ -129,15 +115,12 @@ description: nonebot.plugin.load 模块
- **说明:** 声明依赖插件。 - **说明:** 声明依赖插件。
- **参数** - **参数**
- `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。 - `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。
- **返回** - **返回**
- ModuleType - ModuleType
- **异常** - **异常**
- RuntimeError: 插件无法加载 - RuntimeError: 插件无法加载
## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters} ## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters}
@ -149,15 +132,12 @@ description: nonebot.plugin.load 模块
如果传入了多个插件名称,返回值会自动取交集。 如果传入了多个插件名称,返回值会自动取交集。
- **参数** - **参数**
- `*names` (str): 插件名称列表。 - `*names` (str): 插件名称列表。
- **返回** - **返回**
- set[str] | None - set[str] | None
- **异常** - **异常**
- RuntimeError: 插件未加载 - RuntimeError: 插件未加载
- ValueError: 插件缺少元数据 - ValueError: 插件缺少元数据

View File

@ -16,7 +16,6 @@ description: nonebot.plugin.manager 模块
- **说明:** 插件管理器。 - **说明:** 插件管理器。
- **参数** - **参数**
- `plugins` (Iterable[str] | None): 独立插件模块名集合。 - `plugins` (Iterable[str] | None): 独立插件模块名集合。
- `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。 - `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。
@ -54,11 +53,9 @@ description: nonebot.plugin.manager 模块
可以使用完整插件模块名或者插件标识符加载。 可以使用完整插件模块名或者插件标识符加载。
- **参数** - **参数**
- `name` (str): 插件名称或插件标识符。 - `name` (str): 插件名称或插件标识符。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins} ### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins}
@ -70,7 +67,6 @@ description: nonebot.plugin.manager 模块
empty empty
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _class_ `PluginFinder(<auto>)` {#PluginFinder} ## _class_ `PluginFinder(<auto>)` {#PluginFinder}
@ -82,7 +78,6 @@ description: nonebot.plugin.manager 模块
### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec} ### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec}
- **参数** - **参数**
- `fullname` (str) - `fullname` (str)
- `path` (Sequence[str] | None) - `path` (Sequence[str] | None)
@ -90,13 +85,11 @@ description: nonebot.plugin.manager 模块
- `target` (ModuleType | None) - `target` (ModuleType | None)
- **返回** - **返回**
- untyped - untyped
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader} ## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
- **参数** - **参数**
- `manager` (PluginManager) - `manager` (PluginManager)
- `fullname` (str) - `fullname` (str)
@ -106,19 +99,15 @@ description: nonebot.plugin.manager 模块
### _method_ `create_module(spec)` {#PluginLoader-create-module} ### _method_ `create_module(spec)` {#PluginLoader-create-module}
- **参数** - **参数**
- `spec` - `spec`
- **返回** - **返回**
- ModuleType | None - ModuleType | None
### _method_ `exec_module(module)` {#PluginLoader-exec-module} ### _method_ `exec_module(module)` {#PluginLoader-exec-module}
- **参数** - **参数**
- `module` (ModuleType) - `module` (ModuleType)
- **返回** - **返回**
- None - None

View File

@ -80,7 +80,6 @@ description: nonebot.plugin.model 模块
empty empty
- **返回** - **返回**
- set[type[[Adapter](../adapters/index.md#Adapter)]] | None - set[type[[Adapter](../adapters/index.md#Adapter)]] | None
## _class_ `Plugin(<auto>)` {#Plugin} ## _class_ `Plugin(<auto>)` {#Plugin}

View File

@ -14,11 +14,9 @@ description: nonebot.plugin.on 模块
- **说明:** 存储一个事件响应器到插件。 - **说明:** 存储一个事件响应器到插件。
- **参数** - **参数**
- `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器 - `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器
- **返回** - **返回**
- None - None
## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin} ## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin}
@ -30,11 +28,9 @@ description: nonebot.plugin.on 模块
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。 **Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_matcher_module(depth=...)` {#get-matcher-module} ## _def_ `get_matcher_module(depth=...)` {#get-matcher-module}
@ -46,11 +42,9 @@ description: nonebot.plugin.on 模块
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。 **Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- ModuleType | None - ModuleType | None
## _def_ `get_matcher_source(depth=...)` {#get-matcher-source} ## _def_ `get_matcher_source(depth=...)` {#get-matcher-source}
@ -58,11 +52,9 @@ description: nonebot.plugin.on 模块
- **说明:** 获取事件响应器定义所在源码信息。 - **说明:** 获取事件响应器定义所在源码信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- MatcherSource | None - MatcherSource | None
## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on} ## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on}
@ -70,7 +62,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个基础事件响应器,可自定义类型。 - **说明:** 注册一个基础事件响应器,可自定义类型。
- **参数** - **参数**
- `type` (str): 事件响应器类型 - `type` (str): 事件响应器类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -90,7 +81,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent} ## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent}
@ -98,7 +88,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个元事件响应器。 - **说明:** 注册一个元事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -116,7 +105,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message} ## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message}
@ -124,7 +112,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器。 - **说明:** 注册一个消息事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -142,7 +129,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice} ## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice}
@ -150,7 +136,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个通知事件响应器。 - **说明:** 注册一个通知事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -168,7 +153,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request} ## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request}
@ -176,7 +160,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个请求事件响应器。 - **说明:** 注册一个请求事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -194,7 +177,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith} ## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith}
@ -202,7 +184,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头内容 - `msg` (str | tuple[str, ...]): 指定消息开头内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -224,7 +205,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith} ## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith}
@ -232,7 +212,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息结尾内容 - `msg` (str | tuple[str, ...]): 指定消息结尾内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -254,7 +233,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch} ## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch}
@ -262,7 +240,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容 - `msg` (str | tuple[str, ...]): 指定消息全匹配内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -284,7 +261,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword} ## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword}
@ -292,7 +268,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。 - **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
- **参数** - **参数**
- `keywords` (set[str]): 关键词列表 - `keywords` (set[str]): 关键词列表
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -312,7 +287,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command} ## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command}
@ -324,7 +298,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_ 命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -348,7 +321,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command} ## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command}
@ -363,7 +335,6 @@ description: nonebot.plugin.on 模块
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。 通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -387,7 +358,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex} ## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex}
@ -399,7 +369,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_ 命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
- **参数** - **参数**
- `pattern` (str): 正则表达式 - `pattern` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则匹配标志 - `flags` (int | re.RegexFlag): 正则匹配标志
@ -421,7 +390,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type} ## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type}
@ -429,7 +397,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。 - **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
- **参数** - **参数**
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型 - `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -449,13 +416,11 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup} ## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup}
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]) - `cmd` (str | tuple[str, ...])
- `prefix_aliases` (bool) - `prefix_aliases` (bool)
@ -481,7 +446,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值 - **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -505,7 +469,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command} ### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command}
@ -513,7 +476,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值 - **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -537,13 +499,11 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup} ## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup}
- **参数** - **参数**
- `type` (str) - `type` (str)
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None) - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None)
@ -567,7 +527,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个基础事件响应器,可自定义类型。 - **说明:** 注册一个基础事件响应器,可自定义类型。
- **参数** - **参数**
- `type` (str): 事件响应器类型 - `type` (str): 事件响应器类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -587,7 +546,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent} ### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent}
@ -595,7 +553,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个元事件响应器。 - **说明:** 注册一个元事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -613,7 +570,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message} ### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message}
@ -621,7 +577,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器。 - **说明:** 注册一个消息事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -639,7 +594,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice} ### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice}
@ -647,7 +601,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个通知事件响应器。 - **说明:** 注册一个通知事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -665,7 +618,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request} ### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request}
@ -673,7 +625,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个请求事件响应器。 - **说明:** 注册一个请求事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -691,7 +642,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith} ### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith}
@ -699,7 +649,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头内容 - `msg` (str | tuple[str, ...]): 指定消息开头内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -721,7 +670,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith} ### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith}
@ -729,7 +677,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息结尾内容 - `msg` (str | tuple[str, ...]): 指定消息结尾内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -751,7 +698,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch} ### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch}
@ -759,7 +705,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容 - `msg` (str | tuple[str, ...]): 指定消息全匹配内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -781,7 +726,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword} ### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword}
@ -789,7 +733,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。 - **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
- **参数** - **参数**
- `keywords` (set[str]): 关键词列表 - `keywords` (set[str]): 关键词列表
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -809,7 +752,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command} ### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command}
@ -821,7 +763,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_ 命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名 - `aliases` (set[str | tuple[str, ...]] | None): 命令别名
@ -845,7 +786,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command} ### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command}
@ -860,7 +800,6 @@ description: nonebot.plugin.on 模块
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。 通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名 - `aliases` (set[str | tuple[str, ...]] | None): 命令别名
@ -884,7 +823,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex} ### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex}
@ -896,7 +834,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_ 命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
- **参数** - **参数**
- `pattern` (str): 正则表达式 - `pattern` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则匹配标志 - `flags` (int | re.RegexFlag): 正则匹配标志
@ -918,7 +855,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type} ### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type}
@ -926,7 +862,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。 - **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
- **参数** - **参数**
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型 - `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -946,5 +881,4 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]

View File

@ -22,7 +22,6 @@ description: nonebot.rule 模块
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。 当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
- **参数** - **参数**
- `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker - `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker
- **用法** - **用法**
@ -44,7 +43,6 @@ description: nonebot.rule 模块
- **说明:** 检查是否符合所有规则 - **说明:** 检查是否符合所有规则
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
@ -56,7 +54,6 @@ description: nonebot.rule 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool - bool
## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT} ## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT}
@ -78,7 +75,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否以指定字符串开头。 - **说明:** 检查消息纯文本是否以指定字符串开头。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息开头字符串元组 - `msg` (tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -88,13 +84,11 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本开头。 - **说明:** 匹配消息纯文本开头。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组 - `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule} ## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule}
@ -102,7 +96,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否以指定字符串结尾。 - **说明:** 检查消息纯文本是否以指定字符串结尾。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息结尾字符串元组 - `msg` (tuple[str, ...]): 指定消息结尾字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -112,13 +105,11 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本结尾。 - **说明:** 匹配消息纯文本结尾。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组 - `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule} ## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule}
@ -126,7 +117,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否与指定字符串全匹配。 - **说明:** 检查消息纯文本是否与指定字符串全匹配。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息全匹配字符串元组 - `msg` (tuple[str, ...]): 指定消息全匹配字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -136,13 +126,11 @@ description: nonebot.rule 模块
- **说明:** 完全匹配消息。 - **说明:** 完全匹配消息。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组 - `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `KeywordsRule(*keywords)` {#KeywordsRule} ## _class_ `KeywordsRule(*keywords)` {#KeywordsRule}
@ -150,7 +138,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否包含指定关键字。 - **说明:** 检查消息纯文本是否包含指定关键字。
- **参数** - **参数**
- `*keywords` (str): 指定关键字元组 - `*keywords` (str): 指定关键字元组
## _def_ `keyword(*keywords)` {#keyword} ## _def_ `keyword(*keywords)` {#keyword}
@ -158,11 +145,9 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本关键词。 - **说明:** 匹配消息纯文本关键词。
- **参数** - **参数**
- `*keywords` (str): 指定关键字元组 - `*keywords` (str): 指定关键字元组
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule} ## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule}
@ -170,7 +155,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息是否为指定命令。 - **说明:** 检查消息是否为指定命令。
- **参数** - **参数**
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表 - `cmds` (list[tuple[str, ...]]): 指定命令元组列表
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符 - `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
@ -189,13 +173,11 @@ description: nonebot.rule 模块
通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。 通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。
- **参数** - **参数**
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组 - `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符 - `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
- **用法** - **用法**
@ -231,37 +213,28 @@ description: nonebot.rule 模块
- **重载** - **重载**
**1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]` **1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]`
- **参数** - **参数**
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None) - `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
- `namespace` (None) - `namespace` (None)
- **返回** - **返回**
- tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
**2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]` **2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]`
- **参数** - **参数**
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None) - `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
- `namespace` (T) - `namespace` (T)
- **返回** - **返回**
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
**3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]` **3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]`
- **参数** - **参数**
- `namespace` (T) - `namespace` (T)
- **返回** - **返回**
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule} ## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule}
@ -269,7 +242,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息是否为指定 shell 命令。 - **说明:** 检查消息是否为指定 shell 命令。
- **参数** - **参数**
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表 - `cmds` (list[tuple[str, ...]]): 指定命令元组列表
- `parser` (ArgumentParser | None): 可选参数解析器 - `parser` (ArgumentParser | None): 可选参数解析器
@ -298,13 +270,11 @@ description: nonebot.rule 模块
::: :::
- **参数** - **参数**
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组 - `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
- `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象 - `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
- **用法** - **用法**
@ -330,7 +300,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息字符串是否符合指定正则表达式。 - **说明:** 检查消息字符串是否符合指定正则表达式。
- **参数** - **参数**
- `regex` (str): 正则表达式 - `regex` (str): 正则表达式
- `flags` (int): 正则表达式标记 - `flags` (int): 正则表达式标记
@ -346,13 +315,11 @@ description: nonebot.rule 模块
通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。 通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。
- **参数** - **参数**
- `regex` (str): 正则表达式 - `regex` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则表达式标记 - `flags` (int | re.RegexFlag): 正则表达式标记
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
:::tip 提示 :::tip 提示
@ -380,7 +347,6 @@ description: nonebot.rule 模块
empty empty
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `IsTypeRule(*types)` {#IsTypeRule} ## _class_ `IsTypeRule(*types)` {#IsTypeRule}
@ -388,7 +354,6 @@ description: nonebot.rule 模块
- **说明:** 检查事件类型是否为指定类型。 - **说明:** 检查事件类型是否为指定类型。
- **参数** - **参数**
- `*types` (type[[Event](adapters/index.md#Event)]) - `*types` (type[[Event](adapters/index.md#Event)])
## _def_ `is_type(*types)` {#is-type} ## _def_ `is_type(*types)` {#is-type}
@ -396,9 +361,7 @@ description: nonebot.rule 模块
- **说明:** 匹配事件类型。 - **说明:** 匹配事件类型。
- **参数** - **参数**
- `*types` (type[[Event](adapters/index.md#Event)]): 事件类型 - `*types` (type[[Event](adapters/index.md#Event)]): 事件类型
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)

View File

@ -19,31 +19,25 @@ description: nonebot.typing 模块
- **说明:** 标记一个方法为父类 interface 的 implement - **说明:** 标记一个方法为父类 interface 的 implement
- **参数** - **参数**
- `InterfaceClass` (object) - `InterfaceClass` (object)
- **返回** - **返回**
- untyped - untyped
## _def_ `type_has_args(type_)` {#type-has-args} ## _def_ `type_has_args(type_)` {#type-has-args}
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `origin_is_union(origin)` {#origin-is-union} ## _def_ `origin_is_union(origin)` {#origin-is-union}
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `origin_is_literal(origin)` {#origin-is-literal} ## _def_ `origin_is_literal(origin)` {#origin-is-literal}
@ -51,11 +45,9 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 Literal 类型 - **说明:** 判断是否是 Literal 类型
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `all_literal_values(type_)` {#all-literal-values} ## _def_ `all_literal_values(type_)` {#all-literal-values}
@ -63,11 +55,9 @@ description: nonebot.typing 模块
- **说明:** 获取 Literal 类型包含的所有值 - **说明:** 获取 Literal 类型包含的所有值
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- list[Any] - list[Any]
## _def_ `origin_is_annotated(origin)` {#origin-is-annotated} ## _def_ `origin_is_annotated(origin)` {#origin-is-annotated}
@ -75,11 +65,9 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 Annotated 类型 - **说明:** 判断是否是 Annotated 类型
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `is_none_type(type_)` {#is-none-type} ## _def_ `is_none_type(type_)` {#is-none-type}
@ -87,17 +75,14 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 None 类型 - **说明:** 判断是否是 None 类型
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref} ## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref}
- **参数** - **参数**
- `ref` (ForwardRef) - `ref` (ForwardRef)
- `globalns` (dict[str, Any]) - `globalns` (dict[str, Any])
@ -105,7 +90,6 @@ description: nonebot.typing 模块
- `localns` (dict[str, Any]) - `localns` (dict[str, Any])
- **返回** - **返回**
- Any - Any
## _class_ `StateFlag(<auto>)` {#StateFlag} ## _class_ `StateFlag(<auto>)` {#StateFlag}
@ -129,7 +113,6 @@ description: nonebot.typing 模块
Bot 连接建立时钩子函数 Bot 连接建立时钩子函数
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- DefaultParam: 带有默认值的参数 - DefaultParam: 带有默认值的参数
@ -143,7 +126,6 @@ description: nonebot.typing 模块
Bot 连接断开时钩子函数 Bot 连接断开时钩子函数
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- DefaultParam: 带有默认值的参数 - DefaultParam: 带有默认值的参数
@ -169,7 +151,6 @@ description: nonebot.typing 模块
事件预处理函数 EventPreProcessor 类型 事件预处理函数 EventPreProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -185,7 +166,6 @@ description: nonebot.typing 模块
事件后处理函数 EventPostProcessor 类型 事件后处理函数 EventPostProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -201,7 +181,6 @@ description: nonebot.typing 模块
事件响应器运行前预处理函数 RunPreProcessor 类型 事件响应器运行前预处理函数 RunPreProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -218,7 +197,6 @@ description: nonebot.typing 模块
事件响应器运行后后处理函数 RunPostProcessor 类型 事件响应器运行后后处理函数 RunPostProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -236,7 +214,6 @@ description: nonebot.typing 模块
RuleChecker 即判断是否响应事件的处理函数。 RuleChecker 即判断是否响应事件的处理函数。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -252,7 +229,6 @@ description: nonebot.typing 模块
PermissionChecker 即判断事件是否满足权限的处理函数。 PermissionChecker 即判断事件是否满足权限的处理函数。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -273,7 +249,6 @@ description: nonebot.typing 模块
TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message` TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message`
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -290,7 +265,6 @@ description: nonebot.typing 模块
PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。 PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象

View File

@ -18,11 +18,9 @@ description: nonebot.utils 模块
参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color) 参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color)
- **参数** - **参数**
- `s` (str): 需要转义的字符串 - `s` (str): 需要转义的字符串
- **返回** - **返回**
- str - str
## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update} ## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update}
@ -30,13 +28,11 @@ description: nonebot.utils 模块
- **说明:** 深度更新合并字典 - **说明:** 深度更新合并字典
- **参数** - **参数**
- `mapping` (dict[K, Any]) - `mapping` (dict[K, Any])
- `*updating_mappings` (dict[K, Any]) - `*updating_mappings` (dict[K, Any])
- **返回** - **返回**
- dict[K, Any] - dict[K, Any]
## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass} ## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass}
@ -44,13 +40,11 @@ description: nonebot.utils 模块
- **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。 - **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。
- **参数** - **参数**
- `cls` (Any) - `cls` (Any)
- `class_or_tuple` (type[Any] | tuple[type[Any], ...]) - `class_or_tuple` (type[Any] | tuple[type[Any], ...])
- **返回** - **返回**
- bool - bool
## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass} ## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass}
@ -60,7 +54,6 @@ description: nonebot.utils 模块
检查 cls 是否是 class_or_tuple 中的一个类型子类。 检查 cls 是否是 class_or_tuple 中的一个类型子类。
特别的: 特别的:
- 如果 cls 是 `typing.Union``types.UnionType` 类型, - 如果 cls 是 `typing.Union``types.UnionType` 类型,
则会检查其中的所有类型是否是 class_or_tuple 中一个类型的子类或 None。 则会检查其中的所有类型是否是 class_or_tuple 中一个类型的子类或 None。
- 如果 cls 是 `typing.Literal` 类型, - 如果 cls 是 `typing.Literal` 类型,
@ -70,13 +63,11 @@ description: nonebot.utils 模块
是否是 class_or_tuple 中一个类型的子类或 None。 是否是 class_or_tuple 中一个类型的子类或 None。
- **参数** - **参数**
- `cls` (Any) - `cls` (Any)
- `class_or_tuple` (type[Any] | tuple[type[Any], ...]) - `class_or_tuple` (type[Any] | tuple[type[Any], ...])
- **返回** - **返回**
- bool - bool
## _def_ `type_is_complex(type_)` {#type-is-complex} ## _def_ `type_is_complex(type_)` {#type-is-complex}
@ -84,11 +75,9 @@ description: nonebot.utils 模块
- **说明:** 检查 type\_ 是否是复杂类型 - **说明:** 检查 type\_ 是否是复杂类型
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable} ## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable}
@ -96,11 +85,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个 callable 协程函数 - **说明:** 检查 call 是否是一个 callable 协程函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `is_gen_callable(call)` {#is-gen-callable} ## _def_ `is_gen_callable(call)` {#is-gen-callable}
@ -108,11 +95,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个生成器函数 - **说明:** 检查 call 是否是一个生成器函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable} ## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable}
@ -120,11 +105,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个异步生成器函数 - **说明:** 检查 call 是否是一个异步生成器函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `run_sync(call)` {#run-sync} ## _def_ `run_sync(call)` {#run-sync}
@ -132,11 +115,9 @@ description: nonebot.utils 模块
- **说明:** 一个用于包装 sync function 为 async function 的装饰器 - **说明:** 一个用于包装 sync function 为 async function 的装饰器
- **参数** - **参数**
- `call` ((P) -> R): 被装饰的同步函数 - `call` ((P) -> R): 被装饰的同步函数
- **返回** - **返回**
- (P) -> Coroutine[None, None, R] - (P) -> Coroutine[None, None, R]
## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager} ## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager}
@ -144,11 +125,9 @@ description: nonebot.utils 模块
- **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数 - **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数
- **参数** - **参数**
- `cm` (AbstractContextManager[T]) - `cm` (AbstractContextManager[T])
- **返回** - **返回**
- AsyncGenerator[T, None] - AsyncGenerator[T, None]
## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch} ## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch}
@ -158,9 +137,7 @@ description: nonebot.utils 模块
- **重载** - **重载**
**1.** `(coro, exc, return_on_err=None) -> T | None` **1.** `(coro, exc, return_on_err=None) -> T | None`
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]) - `coro` (Coroutine[Any, Any, T])
- `exc` (tuple[type[Exception], ...]) - `exc` (tuple[type[Exception], ...])
@ -168,13 +145,10 @@ description: nonebot.utils 模块
- `return_on_err` (None) - `return_on_err` (None)
- **返回** - **返回**
- T | None - T | None
**2.** `(coro, exc, return_on_err) -> T | R` **2.** `(coro, exc, return_on_err) -> T | R`
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]) - `coro` (Coroutine[Any, Any, T])
- `exc` (tuple[type[Exception], ...]) - `exc` (tuple[type[Exception], ...])
@ -182,11 +156,9 @@ description: nonebot.utils 模块
- `return_on_err` (R) - `return_on_err` (R)
- **返回** - **返回**
- T | R - T | R
- **参数** - **参数**
- `coro`: 要运行的协程 - `coro`: 要运行的协程
- `exc`: 要捕获的异常 - `exc`: 要捕获的异常
@ -202,21 +174,17 @@ description: nonebot.utils 模块
- **说明:** 运行协程并在取消时屏蔽取消异常。 - **说明:** 运行协程并在取消时屏蔽取消异常。
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]): 要运行的协程 - `coro` (Coroutine[Any, Any, T]): 要运行的协程
- **返回** - **返回**
- T: 协程的返回值 - T: 协程的返回值
## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group} ## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group}
- **参数** - **参数**
- `exc_group` (BaseExceptionGroup[E]) - `exc_group` (BaseExceptionGroup[E])
- **返回** - **返回**
- Generator[E, None, None] - Generator[E, None, None]
## _def_ `get_name(obj)` {#get-name} ## _def_ `get_name(obj)` {#get-name}
@ -224,11 +192,9 @@ description: nonebot.utils 模块
- **说明:** 获取对象的名称 - **说明:** 获取对象的名称
- **参数** - **参数**
- `obj` (Any) - `obj` (Any)
- **返回** - **返回**
- str - str
## _def_ `path_to_module_name(path)` {#path-to-module-name} ## _def_ `path_to_module_name(path)` {#path-to-module-name}
@ -236,11 +202,9 @@ description: nonebot.utils 模块
- **说明:** 转换路径为模块名 - **说明:** 转换路径为模块名
- **参数** - **参数**
- `path` (Path) - `path` (Path)
- **返回** - **返回**
- str - str
## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation} ## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation}
@ -248,7 +212,6 @@ description: nonebot.utils 模块
- **说明:** 解析并导入点分表示法的对象 - **说明:** 解析并导入点分表示法的对象
- **参数** - **参数**
- `obj_str` (str) - `obj_str` (str)
- `default_attr` (str) - `default_attr` (str)
@ -256,7 +219,6 @@ description: nonebot.utils 模块
- `default_prefix` (str | None) - `default_prefix` (str | None)
- **返回** - **返回**
- Any - Any
## _class_ `classproperty(func)` {#classproperty} ## _class_ `classproperty(func)` {#classproperty}
@ -264,7 +226,6 @@ description: nonebot.utils 模块
- **说明:** 类属性装饰器 - **说明:** 类属性装饰器
- **参数** - **参数**
- `func` ((Any) -> T) - `func` ((Any) -> T)
## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder} ## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder}
@ -278,11 +239,9 @@ description: nonebot.utils 模块
### _method_ `default(o)` {#DataclassEncoder-default} ### _method_ `default(o)` {#DataclassEncoder-default}
- **参数** - **参数**
- `o` - `o`
- **返回** - **返回**
- untyped - untyped
## _def_ `logger_wrapper(logger_name)` {#logger-wrapper} ## _def_ `logger_wrapper(logger_name)` {#logger-wrapper}
@ -290,15 +249,12 @@ description: nonebot.utils 模块
- **说明:** 用于打印 adapter 的日志。 - **说明:** 用于打印 adapter 的日志。
- **参数** - **参数**
- `logger_name` (str): adapter 的名称 - `logger_name` (str): adapter 的名称
- **返回** - **返回**
- untyped: 日志记录函数 - untyped: 日志记录函数
日志记录函数的参数: 日志记录函数的参数:
- level: 日志等级 - level: 日志等级
- message: 日志信息 - message: 日志信息
- exception: 异常信息 - exception: 异常信息

View File

@ -278,7 +278,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
`Arparma` 有如下属性: `Arparma` 有如下属性:
- 调试类 - 调试类
- matched: 是否匹配成功 - matched: 是否匹配成功
- error_data: 解析失败时剩余的数据 - error_data: 解析失败时剩余的数据
- error_info: 解析失败时的异常内容 - error_info: 解析失败时的异常内容

View File

@ -155,7 +155,6 @@ async def test_example(app: App):
1. `should_call_send` 1. `should_call_send`
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数: 定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
- `event`:回复的目标事件。 - `event`:回复的目标事件。
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。 - `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
- `result`send 的返回值,将会返回给插件。 - `result`send 的返回值,将会返回给插件。
@ -164,7 +163,6 @@ async def test_example(app: App):
2. `should_call_api` 2. `should_call_api`
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数: 定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
- `api`API 名称。 - `api`API 名称。
- `data`:预期的请求数据。 - `data`:预期的请求数据。
- `result`call_api 的返回值,将会返回给插件。 - `result`call_api 的返回值,将会返回给插件。

View File

@ -20,7 +20,6 @@ description: nonebot.adapters 模块
通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。 通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。
- **参数** - **参数**
- `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例 - `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例
- `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数 - `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数
@ -46,7 +45,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _property_ `config` {#Adapter-config} ### _property_ `config` {#Adapter-config}
@ -64,11 +62,9 @@ description: nonebot.adapters 模块
当有新的 [Bot](#Bot) 实例连接建立成功时调用。 当有新的 [Bot](#Bot) 实例连接建立成功时调用。
- **参数** - **参数**
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例 - `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
- **返回** - **返回**
- None - None
### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect} ### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect}
@ -80,11 +76,9 @@ description: nonebot.adapters 模块
当有 [Bot](#Bot) 实例连接断开时调用。 当有 [Bot](#Bot) 实例连接断开时调用。
- **参数** - **参数**
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例 - `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
- **返回** - **返回**
- None - None
### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server} ### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server}
@ -92,11 +86,9 @@ description: nonebot.adapters 模块
- **说明:** 设置一个 HTTP 服务器路由配置 - **说明:** 设置一个 HTTP 服务器路由配置
- **参数** - **参数**
- `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server}
@ -104,11 +96,9 @@ description: nonebot.adapters 模块
- **说明:** 设置一个 WebSocket 服务器路由配置 - **说明:** 设置一个 WebSocket 服务器路由配置
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup))
- **返回** - **返回**
- untyped - untyped
### _async method_ `request(setup)` {#Adapter-request} ### _async method_ `request(setup)` {#Adapter-request}
@ -116,11 +106,9 @@ description: nonebot.adapters 模块
- **说明:** 进行一个 HTTP 客户端请求 - **说明:** 进行一个 HTTP 客户端请求
- **参数** - **参数**
- `setup` ([Request](../drivers/index.md#Request)) - `setup` ([Request](../drivers/index.md#Request))
- **返回** - **返回**
- [Response](../drivers/index.md#Response) - [Response](../drivers/index.md#Response)
### _method_ `websocket(setup)` {#Adapter-websocket} ### _method_ `websocket(setup)` {#Adapter-websocket}
@ -128,21 +116,17 @@ description: nonebot.adapters 模块
- **说明:** 建立一个 WebSocket 客户端连接请求 - **说明:** 建立一个 WebSocket 客户端连接请求
- **参数** - **参数**
- `setup` ([Request](../drivers/index.md#Request)) - `setup` ([Request](../drivers/index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None] - AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None]
### _method_ `on_ready(func)` {#Adapter-on-ready} ### _method_ `on_ready(func)` {#Adapter-on-ready}
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
## _abstract class_ `Bot(adapter, self_id)` {#Bot} ## _abstract class_ `Bot(adapter, self_id)` {#Bot}
@ -154,7 +138,6 @@ description: nonebot.adapters 模块
用于处理上报消息,并提供 API 调用接口。 用于处理上报消息,并提供 API 调用接口。
- **参数** - **参数**
- `adapter` ([Adapter](#Adapter)): 协议适配器实例 - `adapter` ([Adapter](#Adapter)): 协议适配器实例
- `self_id` (str): 机器人 ID - `self_id` (str): 机器人 ID
@ -188,13 +171,11 @@ description: nonebot.adapters 模块
- **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用 - **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
- **参数** - **参数**
- `api` (str): API 名称 - `api` (str): API 名称
- `**data` (Any): API 数据 - `**data` (Any): API 数据
- **返回** - **返回**
- Any - Any
- **用法** - **用法**
@ -209,7 +190,6 @@ description: nonebot.adapters 模块
- **说明:** 调用机器人基础发送消息接口 - **说明:** 调用机器人基础发送消息接口
- **参数** - **参数**
- `event` ([Event](#Event)): 上报事件 - `event` ([Event](#Event)): 上报事件
- `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息 - `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息
@ -217,7 +197,6 @@ description: nonebot.adapters 模块
- `**kwargs` (Any): 任意额外参数 - `**kwargs` (Any): 任意额外参数
- **返回** - **返回**
- Any - Any
### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api} ### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api}
@ -227,17 +206,14 @@ description: nonebot.adapters 模块
调用 api 预处理。 调用 api 预处理。
钩子函数参数: 钩子函数参数:
- bot: 当前 bot 对象 - bot: 当前 bot 对象
- api: 调用的 api 名称 - api: 调用的 api 名称
- data: api 调用的参数字典 - data: api 调用的参数字典
- **参数** - **参数**
- `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook)) - `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook))
- **返回** - **返回**
- [T_CallingAPIHook](../typing.md#T-CallingAPIHook) - [T_CallingAPIHook](../typing.md#T-CallingAPIHook)
### _classmethod_ `on_called_api(func)` {#Bot-on-called-api} ### _classmethod_ `on_called_api(func)` {#Bot-on-called-api}
@ -247,7 +223,6 @@ description: nonebot.adapters 模块
调用 api 后处理。 调用 api 后处理。
钩子函数参数: 钩子函数参数:
- bot: 当前 bot 对象 - bot: 当前 bot 对象
- exception: 调用 api 时发生的错误 - exception: 调用 api 时发生的错误
- api: 调用的 api 名称 - api: 调用的 api 名称
@ -255,11 +230,9 @@ description: nonebot.adapters 模块
- result: api 调用的返回 - result: api 调用的返回
- **参数** - **参数**
- `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook)) - `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook))
- **返回** - **返回**
- [T_CalledAPIHook](../typing.md#T-CalledAPIHook) - [T_CalledAPIHook](../typing.md#T-CalledAPIHook)
## _abstract class_ `Event(<auto>)` {#Event} ## _abstract class_ `Event(<auto>)` {#Event}
@ -279,7 +252,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_event_name()` {#Event-get-event-name} ### _abstract method_ `get_event_name()` {#Event-get-event-name}
@ -291,7 +263,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_event_description()` {#Event-get-event-description} ### _abstract method_ `get_event_description()` {#Event-get-event-description}
@ -303,7 +274,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _method_ `get_log_string()` {#Event-get-log-string} ### _method_ `get_log_string()` {#Event-get-log-string}
@ -320,11 +290,9 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
- **异常** - **异常**
- NoLogException: 希望 NoneBot 隐藏该事件日志 - NoLogException: 希望 NoneBot 隐藏该事件日志
### _abstract method_ `get_user_id()` {#Event-get-user-id} ### _abstract method_ `get_user_id()` {#Event-get-user-id}
@ -336,7 +304,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_session_id()` {#Event-get-session-id} ### _abstract method_ `get_session_id()` {#Event-get-session-id}
@ -348,7 +315,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `get_message()` {#Event-get-message} ### _abstract method_ `get_message()` {#Event-get-message}
@ -360,7 +326,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- [Message](#Message) - [Message](#Message)
### _method_ `get_plaintext()` {#Event-get-plaintext} ### _method_ `get_plaintext()` {#Event-get-plaintext}
@ -376,7 +341,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract method_ `is_tome()` {#Event-is-tome} ### _abstract method_ `is_tome()` {#Event-is-tome}
@ -388,7 +352,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- bool - bool
## _abstract class_ `Message(<auto>)` {#Message} ## _abstract class_ `Message(<auto>)` {#Message}
@ -396,7 +359,6 @@ description: nonebot.adapters 模块
- **说明:** 消息序列 - **说明:** 消息序列
- **参数** - **参数**
- `message`: 消息内容 - `message`: 消息内容
### _classmethod_ `template(format_string)` {#Message-template} ### _classmethod_ `template(format_string)` {#Message-template}
@ -410,11 +372,9 @@ description: nonebot.adapters 模块
可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。 可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。
- **参数** - **参数**
- `format_string` (str | TM): 格式化模板 - `format_string` (str | TM): 格式化模板
- **返回** - **返回**
- [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器 - [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器
### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class} ### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class}
@ -426,7 +386,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- type[TMS] - type[TMS]
### _abstract staticmethod_ `_construct(msg)` {#Message--construct} ### _abstract staticmethod_ `_construct(msg)` {#Message--construct}
@ -434,11 +393,9 @@ description: nonebot.adapters 模块
- **说明:** 构造消息数组 - **说明:** 构造消息数组
- **参数** - **参数**
- `msg` (str) - `msg` (str)
- **返回** - **返回**
- Iterable[TMS] - Iterable[TMS]
### _method_ `__getitem__(args)` {#Message---getitem--} ### _method_ `__getitem__(args)` {#Message---getitem--}
@ -446,53 +403,38 @@ description: nonebot.adapters 模块
- **重载** - **重载**
**1.** `(args) -> Self` **1.** `(args) -> Self`
- **参数** - **参数**
- `args` (str): 消息段类型 - `args` (str): 消息段类型
- **返回** - **返回**
- Self: 所有类型为 `args` 的消息段 - Self: 所有类型为 `args` 的消息段
**2.** `(args) -> TMS` **2.** `(args) -> TMS`
- **参数** - **参数**
- `args` (tuple[str, int]): 消息段类型和索引 - `args` (tuple[str, int]): 消息段类型和索引
- **返回** - **返回**
- TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个 - TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个
**3.** `(args) -> Self` **3.** `(args) -> Self`
- **参数** - **参数**
- `args` (tuple[str, slice]): 消息段类型和切片 - `args` (tuple[str, slice]): 消息段类型和切片
- **返回** - **返回**
- Self: 类型为 `args[0]` 的消息段切片 `args[1]` - Self: 类型为 `args[0]` 的消息段切片 `args[1]`
**4.** `(args) -> TMS` **4.** `(args) -> TMS`
- **参数** - **参数**
- `args` (int): 索引 - `args` (int): 索引
- **返回** - **返回**
- TMS: 第 `args` 个消息段 - TMS: 第 `args` 个消息段
**5.** `(args) -> Self` **5.** `(args) -> Self`
- **参数** - **参数**
- `args` (slice): 切片 - `args` (slice): 切片
- **返回** - **返回**
- Self: 消息切片 `args` - Self: 消息切片 `args`
### _method_ `__contains__(value)` {#Message---contains--} ### _method_ `__contains__(value)` {#Message---contains--}
@ -500,11 +442,9 @@ description: nonebot.adapters 模块
- **说明:** 检查消息段是否存在 - **说明:** 检查消息段是否存在
- **参数** - **参数**
- `value` (TMS | str): 消息段或消息段类型 - `value` (TMS | str): 消息段或消息段类型
- **返回** - **返回**
- bool: 消息内是否存在给定消息段或给定类型的消息段 - bool: 消息内是否存在给定消息段或给定类型的消息段
### _method_ `has(value)` {#Message-has} ### _method_ `has(value)` {#Message-has}
@ -512,11 +452,9 @@ description: nonebot.adapters 模块
- **说明:** 与 [`__contains__`](#Message---contains--) 相同 - **说明:** 与 [`__contains__`](#Message---contains--) 相同
- **参数** - **参数**
- `value` (TMS | str) - `value` (TMS | str)
- **返回** - **返回**
- bool - bool
### _method_ `index(value, *args)` {#Message-index} ### _method_ `index(value, *args)` {#Message-index}
@ -524,7 +462,6 @@ description: nonebot.adapters 模块
- **说明:** 索引消息段 - **说明:** 索引消息段
- **参数** - **参数**
- `value` (TMS | str): 消息段或者消息段类型 - `value` (TMS | str): 消息段或者消息段类型
- `*args` (SupportsIndex) - `*args` (SupportsIndex)
@ -532,11 +469,9 @@ description: nonebot.adapters 模块
- `arg`: start 与 end - `arg`: start 与 end
- **返回** - **返回**
- int: 索引 index - int: 索引 index
- **异常** - **异常**
- ValueError: 消息段不存在 - ValueError: 消息段不存在
### _method_ `get(type_, count=None)` {#Message-get} ### _method_ `get(type_, count=None)` {#Message-get}
@ -544,13 +479,11 @@ description: nonebot.adapters 模块
- **说明:** 获取指定类型的消息段 - **说明:** 获取指定类型的消息段
- **参数** - **参数**
- `type_` (str): 消息段类型 - `type_` (str): 消息段类型
- `count` (int | None): 获取个数 - `count` (int | None): 获取个数
- **返回** - **返回**
- Self: 构建的新消息 - Self: 构建的新消息
### _method_ `count(value)` {#Message-count} ### _method_ `count(value)` {#Message-count}
@ -558,11 +491,9 @@ description: nonebot.adapters 模块
- **说明:** 计算指定消息段的个数 - **说明:** 计算指定消息段的个数
- **参数** - **参数**
- `value` (TMS | str): 消息段或消息段类型 - `value` (TMS | str): 消息段或消息段类型
- **返回** - **返回**
- int: 个数 - int: 个数
### _method_ `only(value)` {#Message-only} ### _method_ `only(value)` {#Message-only}
@ -570,11 +501,9 @@ description: nonebot.adapters 模块
- **说明:** 检查消息中是否仅包含指定消息段 - **说明:** 检查消息中是否仅包含指定消息段
- **参数** - **参数**
- `value` (TMS | str): 指定消息段或消息段类型 - `value` (TMS | str): 指定消息段或消息段类型
- **返回** - **返回**
- bool: 是否仅包含指定消息段 - bool: 是否仅包含指定消息段
### _method_ `append(obj)` {#Message-append} ### _method_ `append(obj)` {#Message-append}
@ -582,11 +511,9 @@ description: nonebot.adapters 模块
- **说明:** 添加一个消息段到消息数组末尾。 - **说明:** 添加一个消息段到消息数组末尾。
- **参数** - **参数**
- `obj` (str | TMS): 要添加的消息段 - `obj` (str | TMS): 要添加的消息段
- **返回** - **返回**
- Self - Self
### _method_ `extend(obj)` {#Message-extend} ### _method_ `extend(obj)` {#Message-extend}
@ -594,11 +521,9 @@ description: nonebot.adapters 模块
- **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。 - **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。
- **参数** - **参数**
- `obj` (Self | Iterable[TMS]): 要添加的消息数组 - `obj` (Self | Iterable[TMS]): 要添加的消息数组
- **返回** - **返回**
- Self - Self
### _method_ `join(iterable)` {#Message-join} ### _method_ `join(iterable)` {#Message-join}
@ -606,11 +531,9 @@ description: nonebot.adapters 模块
- **说明:** 将多个消息连接并将自身作为分割 - **说明:** 将多个消息连接并将自身作为分割
- **参数** - **参数**
- `iterable` (Iterable[TMS | Self]): 要连接的消息 - `iterable` (Iterable[TMS | Self]): 要连接的消息
- **返回** - **返回**
- Self: 连接后的消息 - Self: 连接后的消息
### _method_ `copy()` {#Message-copy} ### _method_ `copy()` {#Message-copy}
@ -622,7 +545,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- Self - Self
### _method_ `include(*types)` {#Message-include} ### _method_ `include(*types)` {#Message-include}
@ -630,11 +552,9 @@ description: nonebot.adapters 模块
- **说明:** 过滤消息 - **说明:** 过滤消息
- **参数** - **参数**
- `*types` (str): 包含的消息段类型 - `*types` (str): 包含的消息段类型
- **返回** - **返回**
- Self: 新构造的消息 - Self: 新构造的消息
### _method_ `exclude(*types)` {#Message-exclude} ### _method_ `exclude(*types)` {#Message-exclude}
@ -642,11 +562,9 @@ description: nonebot.adapters 模块
- **说明:** 过滤消息 - **说明:** 过滤消息
- **参数** - **参数**
- `*types` (str): 不包含的消息段类型 - `*types` (str): 不包含的消息段类型
- **返回** - **返回**
- Self: 新构造的消息 - Self: 新构造的消息
### _method_ `extract_plain_text()` {#Message-extract-plain-text} ### _method_ `extract_plain_text()` {#Message-extract-plain-text}
@ -658,7 +576,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment} ## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment}
@ -690,7 +607,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- type[TM] - type[TM]
### _abstract method_ `__str__()` {#MessageSegment---str--} ### _abstract method_ `__str__()` {#MessageSegment---str--}
@ -702,29 +618,24 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- str - str
### _method_ `__add__(other)` {#MessageSegment---add--} ### _method_ `__add__(other)` {#MessageSegment---add--}
- **参数** - **参数**
- `other` (str | Self | Iterable[Self]) - `other` (str | Self | Iterable[Self])
- **返回** - **返回**
- TM - TM
### _method_ `get(key, default=None)` {#MessageSegment-get} ### _method_ `get(key, default=None)` {#MessageSegment-get}
- **参数** - **参数**
- `key` (str) - `key` (str)
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- untyped - untyped
### _method_ `keys()` {#MessageSegment-keys} ### _method_ `keys()` {#MessageSegment-keys}
@ -734,7 +645,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `values()` {#MessageSegment-values} ### _method_ `values()` {#MessageSegment-values}
@ -744,7 +654,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `items()` {#MessageSegment-items} ### _method_ `items()` {#MessageSegment-items}
@ -754,17 +663,14 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `join(iterable)` {#MessageSegment-join} ### _method_ `join(iterable)` {#MessageSegment-join}
- **参数** - **参数**
- `iterable` (Iterable[Self | TM]) - `iterable` (Iterable[Self | TM])
- **返回** - **返回**
- TM - TM
### _method_ `copy()` {#MessageSegment-copy} ### _method_ `copy()` {#MessageSegment-copy}
@ -774,7 +680,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- Self - Self
### _abstract method_ `is_text()` {#MessageSegment-is-text} ### _abstract method_ `is_text()` {#MessageSegment-is-text}
@ -786,7 +691,6 @@ description: nonebot.adapters 模块
empty empty
- **返回** - **返回**
- bool - bool
## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate} ## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate}
@ -794,7 +698,6 @@ description: nonebot.adapters 模块
- **说明:** 消息模板格式化实现类。 - **说明:** 消息模板格式化实现类。
- **参数** - **参数**
- `template` (str | TM): 模板 - `template` (str | TM): 模板
- `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str` - `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str`
@ -804,13 +707,11 @@ description: nonebot.adapters 模块
### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec} ### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec}
- **参数** - **参数**
- `spec` (FormatSpecFunc_T) - `spec` (FormatSpecFunc_T)
- `name` (str | None) - `name` (str | None)
- **返回** - **返回**
- FormatSpecFunc_T - FormatSpecFunc_T
### _method_ `format(*args, **kwargs)` {#MessageTemplate-format} ### _method_ `format(*args, **kwargs)` {#MessageTemplate-format}
@ -818,13 +719,11 @@ description: nonebot.adapters 模块
- **说明:** 根据传入参数和模板生成消息对象 - **说明:** 根据传入参数和模板生成消息对象
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- TF - TF
### _method_ `format_map(mapping)` {#MessageTemplate-format-map} ### _method_ `format_map(mapping)` {#MessageTemplate-format-map}
@ -832,17 +731,14 @@ description: nonebot.adapters 模块
- **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用 - **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用
- **参数** - **参数**
- `mapping` (Mapping[str, Any]) - `mapping` (Mapping[str, Any])
- **返回** - **返回**
- TF - TF
### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat} ### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat}
- **参数** - **参数**
- `format_string` (str) - `format_string` (str)
- `args` (Sequence[Any]) - `args` (Sequence[Any])
@ -850,13 +746,11 @@ description: nonebot.adapters 模块
- `kwargs` (Mapping[str, Any]) - `kwargs` (Mapping[str, Any])
- **返回** - **返回**
- TF - TF
### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field} ### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field}
- **参数** - **参数**
- `field_name` (str) - `field_name` (str)
- `args` (Sequence[Any]) - `args` (Sequence[Any])
@ -864,17 +758,14 @@ description: nonebot.adapters 模块
- `kwargs` (Mapping[str, Any]) - `kwargs` (Mapping[str, Any])
- **返回** - **返回**
- tuple[Any, int | str] - tuple[Any, int | str]
### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field} ### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field}
- **参数** - **参数**
- `value` (Any) - `value` (Any)
- `format_spec` (str) - `format_spec` (str)
- **返回** - **返回**
- Any - Any

View File

@ -36,7 +36,6 @@ description: nonebot.compat 模块
- **说明:** FieldInfo class with extra property for compatibility with pydantic v1 - **说明:** FieldInfo class with extra property for compatibility with pydantic v1
- **参数** - **参数**
- `default` (Any) - `default` (Any)
- `**kwargs` (Any) - `**kwargs` (Any)
@ -82,7 +81,6 @@ description: nonebot.compat 模块
- **说明:** Construct a ModelField from given infos. - **说明:** Construct a ModelField from given infos.
- **参数** - **参数**
- `name` (str) - `name` (str)
- `annotation` (Any) - `annotation` (Any)
@ -90,7 +88,6 @@ description: nonebot.compat 模块
- `field_info` (FieldInfo | None) - `field_info` (FieldInfo | None)
- **返回** - **返回**
- Self - Self
### _method_ `get_default()` {#ModelField-get-default} ### _method_ `get_default()` {#ModelField-get-default}
@ -102,7 +99,6 @@ description: nonebot.compat 模块
empty empty
- **返回** - **返回**
- Any - Any
### _method_ `validate_value(value)` {#ModelField-validate-value} ### _method_ `validate_value(value)` {#ModelField-validate-value}
@ -110,11 +106,9 @@ description: nonebot.compat 模块
- **说明:** Validate the value pass to the field. - **说明:** Validate the value pass to the field.
- **参数** - **参数**
- `value` (Any) - `value` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `extract_field_info(field_info)` {#extract-field-info} ## _def_ `extract_field_info(field_info)` {#extract-field-info}
@ -122,11 +116,9 @@ description: nonebot.compat 模块
- **说明:** Get FieldInfo init kwargs from a FieldInfo instance. - **说明:** Get FieldInfo init kwargs from a FieldInfo instance.
- **参数** - **参数**
- `field_info` (BaseFieldInfo) - `field_info` (BaseFieldInfo)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `model_fields(model)` {#model-fields} ## _def_ `model_fields(model)` {#model-fields}
@ -134,11 +126,9 @@ description: nonebot.compat 模块
- **说明:** Get field list of a model. - **说明:** Get field list of a model.
- **参数** - **参数**
- `model` (type[BaseModel]) - `model` (type[BaseModel])
- **返回** - **返回**
- list[ModelField] - list[ModelField]
## _def_ `model_config(model)` {#model-config} ## _def_ `model_config(model)` {#model-config}
@ -146,17 +136,14 @@ description: nonebot.compat 模块
- **说明:** Get config of a model. - **说明:** Get config of a model.
- **参数** - **参数**
- `model` (type[BaseModel]) - `model` (type[BaseModel])
- **返回** - **返回**
- Any - Any
## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump} ## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump}
- **参数** - **参数**
- `model` (BaseModel) - `model` (BaseModel)
- `include` (set[str] | None) - `include` (set[str] | None)
@ -172,7 +159,6 @@ description: nonebot.compat 模块
- `exclude_none` (bool) - `exclude_none` (bool)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `type_validate_python(type_, data)` {#type-validate-python} ## _def_ `type_validate_python(type_, data)` {#type-validate-python}
@ -180,13 +166,11 @@ description: nonebot.compat 模块
- **说明:** Validate data with given type. - **说明:** Validate data with given type.
- **参数** - **参数**
- `type_` (type[T]) - `type_` (type[T])
- `data` (Any) - `data` (Any)
- **返回** - **返回**
- T - T
## _def_ `type_validate_json(type_, data)` {#type-validate-json} ## _def_ `type_validate_json(type_, data)` {#type-validate-json}
@ -194,13 +178,11 @@ description: nonebot.compat 模块
- **说明:** Validate JSON with given type. - **说明:** Validate JSON with given type.
- **参数** - **参数**
- `type_` (type[T]) - `type_` (type[T])
- `data` (str | bytes) - `data` (str | bytes)
- **返回** - **返回**
- T - T
## _def_ `custom_validation(class_)` {#custom-validation} ## _def_ `custom_validation(class_)` {#custom-validation}
@ -208,9 +190,7 @@ description: nonebot.compat 模块
- **说明:** Use pydantic v1 like validator generator in pydantic v2 - **说明:** Use pydantic v1 like validator generator in pydantic v2
- **参数** - **参数**
- `class_` (type[CVC]) - `class_` (type[CVC])
- **返回** - **返回**
- type[CVC] - type[CVC]

View File

@ -24,7 +24,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。 将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None) - `_env_file` (DOTENV_TYPE | None)
- `_env_file_encoding` (str | None) - `_env_file_encoding` (str | None)
@ -55,7 +54,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
配置方法参考: [配置](https://nonebot.dev/docs/appendices/config) 配置方法参考: [配置](https://nonebot.dev/docs/appendices/config)
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None) - `_env_file` (DOTENV_TYPE | None)
- `_env_file_encoding` (str | None) - `_env_file_encoding` (str | None)

View File

@ -18,7 +18,6 @@ description: nonebot.dependencies 模块
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。 继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -30,7 +29,6 @@ description: nonebot.dependencies 模块
- **说明:** 依赖注入容器 - **说明:** 依赖注入容器
- **参数** - **参数**
- `call`: 依赖注入的可调用对象,可以是任何 Callable 对象 - `call`: 依赖注入的可调用对象,可以是任何 Callable 对象
- `pre_checkers`: 依赖注入解析前的参数检查 - `pre_checkers`: 依赖注入解析前的参数检查
@ -44,31 +42,26 @@ description: nonebot.dependencies 模块
### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params} ### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params}
- **参数** - **参数**
- `call` (\_DependentCallable[R]) - `call` (\_DependentCallable[R])
- `allow_types` (tuple[type[Param], ...]) - `allow_types` (tuple[type[Param], ...])
- **返回** - **返回**
- tuple[[ModelField](../compat.md#ModelField), ...] - tuple[[ModelField](../compat.md#ModelField), ...]
### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless} ### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless}
- **参数** - **参数**
- `parameterless` (tuple[Any, ...]) - `parameterless` (tuple[Any, ...])
- `allow_types` (tuple[type[Param], ...]) - `allow_types` (tuple[type[Param], ...])
- **返回** - **返回**
- tuple[Param, ...] - tuple[Param, ...]
### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse} ### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse}
- **参数** - **参数**
- `call` (\_DependentCallable[R]) - `call` (\_DependentCallable[R])
- `parameterless` (Iterable[Any] | None) - `parameterless` (Iterable[Any] | None)
@ -76,25 +69,20 @@ description: nonebot.dependencies 模块
- `allow_types` (Iterable[type[Param]]) - `allow_types` (Iterable[type[Param]])
- **返回** - **返回**
- Dependent[R] - Dependent[R]
### _async method_ `check(**params)` {#Dependent-check} ### _async method_ `check(**params)` {#Dependent-check}
- **参数** - **参数**
- `**params` (Any) - `**params` (Any)
- **返回** - **返回**
- None - None
### _async method_ `solve(**params)` {#Dependent-solve} ### _async method_ `solve(**params)` {#Dependent-solve}
- **参数** - **参数**
- `**params` (Any) - `**params` (Any)
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]

View File

@ -12,11 +12,9 @@ description: nonebot.dependencies.utils 模块
- **说明:** 获取可调用对象签名 - **说明:** 获取可调用对象签名
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- inspect.Signature - inspect.Signature
## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation} ## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation}
@ -24,13 +22,11 @@ description: nonebot.dependencies.utils 模块
- **说明:** 获取参数的类型注解 - **说明:** 获取参数的类型注解
- **参数** - **参数**
- `param` (inspect.Parameter) - `param` (inspect.Parameter)
- `globalns` (dict[str, Any]) - `globalns` (dict[str, Any])
- **返回** - **返回**
- Any - Any
## _def_ `check_field_type(field, value)` {#check-field-type} ## _def_ `check_field_type(field, value)` {#check-field-type}
@ -38,11 +34,9 @@ description: nonebot.dependencies.utils 模块
- **说明:** 检查字段类型是否匹配 - **说明:** 检查字段类型是否匹配
- **参数** - **参数**
- `field` ([ModelField](../compat.md#ModelField)) - `field` ([ModelField](../compat.md#ModelField))
- `value` (Any) - `value` (Any)
- **返回** - **返回**
- Any - Any

View File

@ -22,7 +22,6 @@ pip install nonebot2[aiohttp]
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session} ## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -38,23 +37,19 @@ pip install nonebot2[aiohttp]
### _async method_ `request(setup)` {#Session-request} ### _async method_ `request(setup)` {#Session-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Session-stream-request} ### _method_ `stream_request(setup, *, chunk_size=1024)` {#Session-stream-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- `chunk_size` (int) - `chunk_size` (int)
- **返回** - **返回**
- AsyncGenerator[[Response](index.md#Response), None] - AsyncGenerator[[Response](index.md#Response), None]
### _async method_ `setup()` {#Session-setup} ### _async method_ `setup()` {#Session-setup}
@ -64,7 +59,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close()` {#Session-close} ### _async method_ `close()` {#Session-close}
@ -74,7 +68,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- None - None
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -88,39 +81,32 @@ pip install nonebot2[aiohttp]
### _async method_ `request(setup)` {#Mixin-request} ### _async method_ `request(setup)` {#Mixin-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Mixin-stream-request} ### _method_ `stream_request(setup, *, chunk_size=1024)` {#Mixin-stream-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- `chunk_size` (int) - `chunk_size` (int)
- **返回** - **返回**
- AsyncGenerator[[Response](index.md#Response), None] - AsyncGenerator[[Response](index.md#Response), None]
### _method_ `websocket(setup)` {#Mixin-websocket} ### _method_ `websocket(setup)` {#Mixin-websocket}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](index.md#WebSocket), None] - AsyncGenerator[[WebSocket](index.md#WebSocket), None]
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session} ### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -134,7 +120,6 @@ pip install nonebot2[aiohttp]
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- Session - Session
## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket} ## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket}
@ -142,7 +127,6 @@ pip install nonebot2[aiohttp]
- **说明:** AIOHTTP Websocket Wrapper - **说明:** AIOHTTP Websocket Wrapper
- **参数** - **参数**
- `request` ([Request](index.md#Request)) - `request` ([Request](index.md#Request))
- `session` (aiohttp.ClientSession) - `session` (aiohttp.ClientSession)
@ -156,19 +140,16 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -178,7 +159,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -188,7 +168,6 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -198,33 +177,27 @@ pip install nonebot2[aiohttp]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -92,7 +92,6 @@ pip install nonebot2[fastapi]
- **说明:** FastAPI 驱动框架。 - **说明:** FastAPI 驱动框架。
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` (NoneBotConfig) - `config` (NoneBotConfig)
@ -124,21 +123,17 @@ pip install nonebot2[fastapi]
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server} ### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
- **参数** - **参数**
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
- **返回** - **返回**
- None - None
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run} ### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
@ -146,7 +141,6 @@ pip install nonebot2[fastapi]
- **说明:** 使用 `uvicorn` 启动 FastAPI - **说明:** 使用 `uvicorn` 启动 FastAPI
- **参数** - **参数**
- `host` (str | None) - `host` (str | None)
- `port` (int | None) - `port` (int | None)
@ -158,7 +152,6 @@ pip install nonebot2[fastapi]
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket} ## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket}
@ -166,7 +159,6 @@ pip install nonebot2[fastapi]
- **说明:** FastAPI WebSocket Wrapper - **说明:** FastAPI WebSocket Wrapper
- **参数** - **参数**
- `request` (BaseRequest) - `request` (BaseRequest)
- `websocket` ([WebSocket](index.md#WebSocket)) - `websocket` ([WebSocket](index.md#WebSocket))
@ -178,19 +170,16 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close} ### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- None - None
### _async method_ `receive()` {#FastAPIWebSocket-receive} ### _async method_ `receive()` {#FastAPIWebSocket-receive}
@ -200,7 +189,6 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text} ### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text}
@ -210,7 +198,6 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes}
@ -220,25 +207,20 @@ pip install nonebot2[fastapi]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text} ### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None

View File

@ -22,7 +22,6 @@ pip install nonebot2[httpx]
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session} ## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -38,23 +37,19 @@ pip install nonebot2[httpx]
### _async method_ `request(setup)` {#Session-request} ### _async method_ `request(setup)` {#Session-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Session-stream-request} ### _method_ `stream_request(setup, *, chunk_size=1024)` {#Session-stream-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- `chunk_size` (int) - `chunk_size` (int)
- **返回** - **返回**
- AsyncGenerator[[Response](index.md#Response), None] - AsyncGenerator[[Response](index.md#Response), None]
### _async method_ `setup()` {#Session-setup} ### _async method_ `setup()` {#Session-setup}
@ -64,7 +59,6 @@ pip install nonebot2[httpx]
empty empty
- **返回** - **返回**
- None - None
### _async method_ `close()` {#Session-close} ### _async method_ `close()` {#Session-close}
@ -74,7 +68,6 @@ pip install nonebot2[httpx]
empty empty
- **返回** - **返回**
- None - None
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -88,29 +81,24 @@ pip install nonebot2[httpx]
### _async method_ `request(setup)` {#Mixin-request} ### _async method_ `request(setup)` {#Mixin-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- [Response](index.md#Response) - [Response](index.md#Response)
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Mixin-stream-request} ### _method_ `stream_request(setup, *, chunk_size=1024)` {#Mixin-stream-request}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- `chunk_size` (int) - `chunk_size` (int)
- **返回** - **返回**
- AsyncGenerator[[Response](index.md#Response), None] - AsyncGenerator[[Response](index.md#Response), None]
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session} ### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -124,13 +112,11 @@ pip install nonebot2[httpx]
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- Session - Session
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -40,11 +40,9 @@ description: nonebot.drivers 模块
- **说明:** 设置一个 HTTP 服务器路由配置 - **说明:** 设置一个 HTTP 服务器路由配置
- **参数** - **参数**
- `setup` ([HTTPServerSetup](#HTTPServerSetup)) - `setup` ([HTTPServerSetup](#HTTPServerSetup))
- **返回** - **返回**
- None - None
### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server} ### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server}
@ -52,23 +50,19 @@ description: nonebot.drivers 模块
- **说明:** 设置一个 WebSocket 服务器路由配置 - **说明:** 设置一个 WebSocket 服务器路由配置
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](#WebSocketServerSetup))
- **返回** - **返回**
- None - None
## _class_ `Cookies(cookies=None)` {#Cookies} ## _class_ `Cookies(cookies=None)` {#Cookies}
- **参数** - **参数**
- `cookies` (CookieTypes) - `cookies` (CookieTypes)
### _method_ `set(name, value, domain="", path="/")` {#Cookies-set} ### _method_ `set(name, value, domain="", path="/")` {#Cookies-set}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `value` (str) - `value` (str)
@ -78,13 +72,11 @@ description: nonebot.drivers 模块
- `path` (str) - `path` (str)
- **返回** - **返回**
- None - None
### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get} ### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `default` (str | None) - `default` (str | None)
@ -94,13 +86,11 @@ description: nonebot.drivers 模块
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- str | None - str | None
### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete} ### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete}
- **参数** - **参数**
- `name` (str) - `name` (str)
- `domain` (str | None) - `domain` (str | None)
@ -108,39 +98,32 @@ description: nonebot.drivers 模块
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- None - None
### _method_ `clear(domain=None, path=None)` {#Cookies-clear} ### _method_ `clear(domain=None, path=None)` {#Cookies-clear}
- **参数** - **参数**
- `domain` (str | None) - `domain` (str | None)
- `path` (str | None) - `path` (str | None)
- **返回** - **返回**
- None - None
### _method_ `update(cookies=None)` {#Cookies-update} ### _method_ `update(cookies=None)` {#Cookies-update}
- **参数** - **参数**
- `cookies` (CookieTypes) - `cookies` (CookieTypes)
- **返回** - **返回**
- None - None
### _method_ `as_header(request)` {#Cookies-as-header} ### _method_ `as_header(request)` {#Cookies-as-header}
- **参数** - **参数**
- `request` (Request) - `request` (Request)
- **返回** - **返回**
- dict[str, str] - dict[str, str]
## _abstract class_ `Driver(env, config)` {#Driver} ## _abstract class_ `Driver(env, config)` {#Driver}
@ -152,7 +135,6 @@ description: nonebot.drivers 模块
驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。 驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。
- **参数** - **参数**
- `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象 - `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象
- `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象 - `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象
@ -180,13 +162,11 @@ description: nonebot.drivers 模块
- **说明:** 注册一个协议适配器 - **说明:** 注册一个协议适配器
- **参数** - **参数**
- `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类 - `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类
- `**kwargs`: 其他传递给适配器的参数 - `**kwargs`: 其他传递给适配器的参数
- **返回** - **返回**
- None - None
### _abstract property_ `type` {#Driver-type} ### _abstract property_ `type` {#Driver-type}
@ -206,13 +186,11 @@ description: nonebot.drivers 模块
- **说明:** 启动驱动框架 - **说明:** 启动驱动框架
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
### _method_ `on_startup(func)` {#Driver-on-startup} ### _method_ `on_startup(func)` {#Driver-on-startup}
@ -220,11 +198,9 @@ description: nonebot.drivers 模块
- **说明:** 注册一个启动时执行的函数 - **说明:** 注册一个启动时执行的函数
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
### _method_ `on_shutdown(func)` {#Driver-on-shutdown} ### _method_ `on_shutdown(func)` {#Driver-on-shutdown}
@ -232,11 +208,9 @@ description: nonebot.drivers 模块
- **说明:** 注册一个停止时执行的函数 - **说明:** 注册一个停止时执行的函数
- **参数** - **参数**
- `func` (LIFESPAN_FUNC) - `func` (LIFESPAN_FUNC)
- **返回** - **返回**
- LIFESPAN_FUNC - LIFESPAN_FUNC
### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect} ### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect}
@ -246,15 +220,12 @@ description: nonebot.drivers 模块
装饰一个函数使他在 bot 连接成功时执行。 装饰一个函数使他在 bot 连接成功时执行。
钩子函数参数: 钩子函数参数:
- bot: 当前连接上的 Bot 对象 - bot: 当前连接上的 Bot 对象
- **参数** - **参数**
- `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook)) - `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook))
- **返回** - **返回**
- [T_BotConnectionHook](../typing.md#T-BotConnectionHook) - [T_BotConnectionHook](../typing.md#T-BotConnectionHook)
### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect} ### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect}
@ -264,15 +235,12 @@ description: nonebot.drivers 模块
装饰一个函数使他在 bot 连接断开时执行。 装饰一个函数使他在 bot 连接断开时执行。
钩子函数参数: 钩子函数参数:
- bot: 当前连接上的 Bot 对象 - bot: 当前连接上的 Bot 对象
- **参数** - **参数**
- `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)) - `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook))
- **返回** - **返回**
- [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook) - [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)
## _var_ `ForwardDriver` {#ForwardDriver} ## _var_ `ForwardDriver` {#ForwardDriver}
@ -306,11 +274,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一个 HTTP 请求 - **说明:** 发送一个 HTTP 请求
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- **返回** - **返回**
- [Response](#Response) - [Response](#Response)
### _abstract method_ `stream_request(setup, *, chunk_size=1024)` {#HTTPClientMixin-stream-request} ### _abstract method_ `stream_request(setup, *, chunk_size=1024)` {#HTTPClientMixin-stream-request}
@ -318,13 +284,11 @@ description: nonebot.drivers 模块
- **说明:** 发送一个 HTTP 流式请求 - **说明:** 发送一个 HTTP 流式请求
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- `chunk_size` (int) - `chunk_size` (int)
- **返回** - **返回**
- AsyncGenerator[[Response](#Response), None] - AsyncGenerator[[Response](#Response), None]
### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session} ### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session}
@ -332,7 +296,6 @@ description: nonebot.drivers 模块
- **说明:** 获取一个 HTTP 会话 - **说明:** 获取一个 HTTP 会话
- **参数** - **参数**
- `params` (QueryTypes) - `params` (QueryTypes)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -346,7 +309,6 @@ description: nonebot.drivers 模块
- `proxy` (str | None) - `proxy` (str | None)
- **返回** - **返回**
- HTTPClientSession - HTTPClientSession
## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup} ## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup}
@ -362,7 +324,6 @@ description: nonebot.drivers 模块
- **参数** - **参数**
auto auto
- `H10: '1.0'` - `H10: '1.0'`
- `H11: '1.1'` - `H11: '1.1'`
@ -386,7 +347,6 @@ description: nonebot.drivers 模块
## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request} ## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request}
- **参数** - **参数**
- `method` (str | bytes) - `method` (str | bytes)
- `url` (URL | str | RawURL) - `url` (URL | str | RawURL)
@ -414,7 +374,6 @@ description: nonebot.drivers 模块
## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response} ## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response}
- **参数** - **参数**
- `status_code` (int) - `status_code` (int)
- `headers` (HeaderTypes) - `headers` (HeaderTypes)
@ -452,7 +411,6 @@ description: nonebot.drivers 模块
## _abstract class_ `WebSocket(*, request)` {#WebSocket} ## _abstract class_ `WebSocket(*, request)` {#WebSocket}
- **参数** - **参数**
- `request` (Request) - `request` (Request)
### _abstract property_ `closed` {#WebSocket-closed} ### _abstract property_ `closed` {#WebSocket-closed}
@ -470,7 +428,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- None - None
### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close}
@ -478,13 +435,11 @@ description: nonebot.drivers 模块
- **说明:** 关闭 WebSocket 连接请求 - **说明:** 关闭 WebSocket 连接请求
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- None - None
### _abstract async method_ `receive()` {#WebSocket-receive} ### _abstract async method_ `receive()` {#WebSocket-receive}
@ -496,7 +451,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _abstract async method_ `receive_text()` {#WebSocket-receive-text} ### _abstract async method_ `receive_text()` {#WebSocket-receive-text}
@ -508,7 +462,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- str - str
### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -520,7 +473,6 @@ description: nonebot.drivers 模块
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send(data)` {#WebSocket-send} ### _async method_ `send(data)` {#WebSocket-send}
@ -528,11 +480,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket text/bytes 信息 - **说明:** 发送一条 WebSocket text/bytes 信息
- **参数** - **参数**
- `data` (str | bytes) - `data` (str | bytes)
- **返回** - **返回**
- None - None
### _abstract async method_ `send_text(data)` {#WebSocket-send-text} ### _abstract async method_ `send_text(data)` {#WebSocket-send-text}
@ -540,11 +490,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket text 信息 - **说明:** 发送一条 WebSocket text 信息
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes}
@ -552,11 +500,9 @@ description: nonebot.drivers 模块
- **说明:** 发送一条 WebSocket binary 信息 - **说明:** 发送一条 WebSocket binary 信息
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin} ## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin}
@ -572,11 +518,9 @@ description: nonebot.drivers 模块
- **说明:** 发起一个 WebSocket 连接 - **说明:** 发起一个 WebSocket 连接
- **参数** - **参数**
- `setup` ([Request](#Request)) - `setup` ([Request](#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](#WebSocket), None] - AsyncGenerator[[WebSocket](#WebSocket), None]
## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup} ## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup}
@ -594,19 +538,14 @@ description: nonebot.drivers 模块
- **重载** - **重载**
**1.** `(driver) -> type[D]` **1.** `(driver) -> type[D]`
- **参数** - **参数**
- `driver` (type[D]) - `driver` (type[D])
- **返回** - **返回**
- type[D] - type[D]
**2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]` **2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]`
- **参数** - **参数**
- `driver` (type[D]) - `driver` (type[D])
- `__m` (type[[Mixin](#Mixin)]) - `__m` (type[[Mixin](#Mixin)])
@ -614,5 +553,4 @@ description: nonebot.drivers 模块
- `*mixins` (type[[Mixin](#Mixin)]) - `*mixins` (type[[Mixin](#Mixin)])
- **返回** - **返回**
- type[CombinedDriver] - type[CombinedDriver]

View File

@ -18,7 +18,6 @@ None 驱动适配
- **说明:** None 驱动框架 - **说明:** None 驱动框架
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))
@ -40,13 +39,11 @@ None 驱动适配
- **说明:** 启动 none driver - **说明:** 启动 none driver
- **参数** - **参数**
- `*args` - `*args`
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
### _method_ `exit(force=False)` {#Driver-exit} ### _method_ `exit(force=False)` {#Driver-exit}
@ -54,9 +51,7 @@ None 驱动适配
- **说明:** 退出 none driver - **说明:** 退出 none driver
- **参数** - **参数**
- `force` (bool): 强制退出 - `force` (bool): 强制退出
- **返回** - **返回**
- untyped - untyped

View File

@ -68,7 +68,6 @@ pip install nonebot2[quart]
- **说明:** Quart 驱动框架 - **说明:** Quart 驱动框架
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` (NoneBotConfig) - `config` (NoneBotConfig)
@ -100,21 +99,17 @@ pip install nonebot2[quart]
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server} ### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
- **参数** - **参数**
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup)) - `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
- **返回** - **返回**
- untyped - untyped
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server} ### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
- **参数** - **参数**
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup)) - `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
- **返回** - **返回**
- None - None
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run} ### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
@ -122,7 +117,6 @@ pip install nonebot2[quart]
- **说明:** 使用 `uvicorn` 启动 Quart - **说明:** 使用 `uvicorn` 启动 Quart
- **参数** - **参数**
- `host` (str | None) - `host` (str | None)
- `port` (int | None) - `port` (int | None)
@ -134,7 +128,6 @@ pip install nonebot2[quart]
- `**kwargs` - `**kwargs`
- **返回** - **返回**
- untyped - untyped
## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket} ## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket}
@ -142,7 +135,6 @@ pip install nonebot2[quart]
- **说明:** Quart WebSocket Wrapper - **说明:** Quart WebSocket Wrapper
- **参数** - **参数**
- `request` (BaseRequest) - `request` (BaseRequest)
- `websocket_ctx` (WebsocketContext) - `websocket_ctx` (WebsocketContext)
@ -154,19 +146,16 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -176,7 +165,6 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -186,7 +174,6 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -196,25 +183,20 @@ pip install nonebot2[quart]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- untyped - untyped

View File

@ -22,11 +22,9 @@ pip install nonebot2[websockets]
## _def_ `catch_closed(func)` {#catch-closed} ## _def_ `catch_closed(func)` {#catch-closed}
- **参数** - **参数**
- `func` ((P) -> CoroutineType[Any, Any, T]) - `func` ((P) -> CoroutineType[Any, Any, T])
- **返回** - **返回**
- (P) -> CoroutineType[Any, Any, T] - (P) -> CoroutineType[Any, Any, T]
## _class_ `Mixin(<auto>)` {#Mixin} ## _class_ `Mixin(<auto>)` {#Mixin}
@ -40,11 +38,9 @@ pip install nonebot2[websockets]
### _method_ `websocket(setup)` {#Mixin-websocket} ### _method_ `websocket(setup)` {#Mixin-websocket}
- **参数** - **参数**
- `setup` ([Request](index.md#Request)) - `setup` ([Request](index.md#Request))
- **返回** - **返回**
- AsyncGenerator[[WebSocket](index.md#WebSocket), None] - AsyncGenerator[[WebSocket](index.md#WebSocket), None]
## _class_ `WebSocket(*, request, websocket)` {#WebSocket} ## _class_ `WebSocket(*, request, websocket)` {#WebSocket}
@ -52,7 +48,6 @@ pip install nonebot2[websockets]
- **说明:** Websockets WebSocket Wrapper - **说明:** Websockets WebSocket Wrapper
- **参数** - **参数**
- `request` ([Request](index.md#Request)) - `request` ([Request](index.md#Request))
- `websocket` (ClientConnection) - `websocket` (ClientConnection)
@ -64,19 +59,16 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `close(code=1000, reason="")` {#WebSocket-close} ### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
- **参数** - **参数**
- `code` (int) - `code` (int)
- `reason` (str) - `reason` (str)
- **返回** - **返回**
- untyped - untyped
### _async method_ `receive()` {#WebSocket-receive} ### _async method_ `receive()` {#WebSocket-receive}
@ -86,7 +78,6 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- str | bytes - str | bytes
### _async method_ `receive_text()` {#WebSocket-receive-text} ### _async method_ `receive_text()` {#WebSocket-receive-text}
@ -96,7 +87,6 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- str - str
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes} ### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
@ -106,33 +96,27 @@ pip install nonebot2[websockets]
empty empty
- **返回** - **返回**
- bytes - bytes
### _async method_ `send_text(data)` {#WebSocket-send-text} ### _async method_ `send_text(data)` {#WebSocket-send-text}
- **参数** - **参数**
- `data` (str) - `data` (str)
- **返回** - **返回**
- None - None
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes} ### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
- **参数** - **参数**
- `data` (bytes) - `data` (bytes)
- **返回** - **返回**
- None - None
## _class_ `Driver(env, config)` {#Driver} ## _class_ `Driver(env, config)` {#Driver}
- **参数** - **参数**
- `env` ([Env](../config.md#Env)) - `env` ([Env](../config.md#Env))
- `config` ([Config](../config.md#Config)) - `config` ([Config](../config.md#Config))

View File

@ -62,7 +62,6 @@ NoneBotException
- **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。 - **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
- **参数** - **参数**
- `reason`: 忽略事件的原因 - `reason`: 忽略事件的原因
## _class_ `SkippedException(<auto>)` {#SkippedException} ## _class_ `SkippedException(<auto>)` {#SkippedException}
@ -101,7 +100,6 @@ NoneBotException
- **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。 - **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。
- **参数** - **参数**
- `result`: 返回的内容 - `result`: 返回的内容
## _class_ `StopPropagation(<auto>)` {#StopPropagation} ## _class_ `StopPropagation(<auto>)` {#StopPropagation}
@ -200,7 +198,6 @@ NoneBotException
- **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。 - **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。
- **参数** - **参数**
- `adapter_name`: 标识 adapter - `adapter_name`: 标识 adapter
## _class_ `NoLogException(<auto>)` {#NoLogException} ## _class_ `NoLogException(<auto>)` {#NoLogException}

View File

@ -60,11 +60,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象 - [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -80,27 +78,20 @@ description: nonebot 模块
- **重载** - **重载**
**1.** `(name) -> Adapter` **1.** `(name) -> Adapter`
- **参数** - **参数**
- `name` (str): 适配器名称 - `name` (str): 适配器名称
- **返回** - **返回**
- [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象 - [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象
**2.** `(name) -> A` **2.** `(name) -> A`
- **参数** - **参数**
- `name` (type[A]): 适配器类型 - `name` (type[A]): 适配器类型
- **返回** - **返回**
- A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象 - A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象
- **异常** - **异常**
- ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册 - ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -121,11 +112,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典 - dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -143,11 +132,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- Any: Server App 对象 - Any: Server App 对象
- **异常** - **异常**
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型 - AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -167,11 +154,9 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- Any: ASGI 对象 - Any: ASGI 对象
- **异常** - **异常**
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型 - AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
@ -192,15 +177,12 @@ description: nonebot 模块
当不提供时,返回一个 [Bot](adapters/index.md#Bot)。 当不提供时,返回一个 [Bot](adapters/index.md#Bot)。
- **参数** - **参数**
- `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性 - `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性
- **返回** - **返回**
- [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象 - [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象
- **异常** - **异常**
- KeyError: 对应 self_id 的 Bot 不存在 - KeyError: 对应 self_id 的 Bot 不存在
- ValueError: 没有传入 self_id 且没有 Bot 可用 - ValueError: 没有传入 self_id 且没有 Bot 可用
@ -224,13 +206,11 @@ description: nonebot 模块
empty empty
- **返回** - **返回**
- dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键 - dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键
[Bot](adapters/index.md#Bot) 对象为值的字典 [Bot](adapters/index.md#Bot) 对象为值的字典
- **异常** - **异常**
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用) - ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
- **用法** - **用法**
@ -250,13 +230,11 @@ description: nonebot 模块
也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。 也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。
- **参数** - **参数**
- `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置 - `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置
- `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里 - `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里
- **返回** - **返回**
- None - None
- **用法** - **用法**
@ -270,13 +248,11 @@ description: nonebot 模块
- **说明:** 启动 NoneBot即运行全局 [Driver](drivers/index.md#Driver) 对象。 - **说明:** 启动 NoneBot即运行全局 [Driver](drivers/index.md#Driver) 对象。
- **参数** - **参数**
- `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数 - `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数
- `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数 - `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数
- **返回** - **返回**
- None - None
- **用法** - **用法**

View File

@ -25,7 +25,6 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
NoneBot 日志记录器对象。 NoneBot 日志记录器对象。
默认信息: 默认信息:
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s` - 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
- 等级: `INFO` ,根据 `config.log_level` 配置改变 - 等级: `INFO` ,根据 `config.log_level` 配置改变
- 输出: 输出至 stdout - 输出: 输出至 stdout
@ -47,11 +46,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
### _method_ `emit(record)` {#LoguruHandler-emit} ### _method_ `emit(record)` {#LoguruHandler-emit}
- **参数** - **参数**
- `record` (logging.LogRecord) - `record` (logging.LogRecord)
- **返回** - **返回**
- untyped - untyped
## _def_ `default_filter(record)` {#default-filter} ## _def_ `default_filter(record)` {#default-filter}
@ -59,11 +56,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
- **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。 - **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
- **参数** - **参数**
- `record` (Record) - `record` (Record)
- **返回** - **返回**
- untyped - untyped
## _var_ `default_format` {#default-format} ## _var_ `default_format` {#default-format}

View File

@ -76,7 +76,6 @@ description: nonebot.matcher 模块
- **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_ - **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_
- **参数** - **参数**
- `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意 - `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意
- `rule` ([Rule](rule.md#Rule) | None): 匹配规则 - `rule` ([Rule](rule.md#Rule) | None): 匹配规则
@ -106,7 +105,6 @@ description: nonebot.matcher 模块
- `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数 - `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数
- **返回** - **返回**
- type[Matcher]: 新的事件响应器类 - type[Matcher]: 新的事件响应器类
### _classmethod_ `destroy()` {#Matcher-destroy} ### _classmethod_ `destroy()` {#Matcher-destroy}
@ -118,7 +116,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- None - None
### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm} ### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm}
@ -126,7 +123,6 @@ description: nonebot.matcher 模块
- **说明:** 检查是否满足触发权限 - **说明:** 检查是否满足触发权限
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): 上报事件 - `event` ([Event](adapters/index.md#Event)): 上报事件
@ -136,7 +132,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool: 是否满足权限 - bool: 是否满足权限
### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule} ### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule}
@ -144,7 +139,6 @@ description: nonebot.matcher 模块
- **说明:** 检查是否满足匹配规则 - **说明:** 检查是否满足匹配规则
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): 上报事件 - `event` ([Event](adapters/index.md#Event)): 上报事件
@ -156,7 +150,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool: 是否满足匹配规则 - bool: 是否满足匹配规则
### _classmethod_ `type_updater(func)` {#Matcher-type-updater} ### _classmethod_ `type_updater(func)` {#Matcher-type-updater}
@ -164,11 +157,9 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数 - **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数
- **参数** - **参数**
- `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数 - `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数
- **返回** - **返回**
- [T_TypeUpdater](typing.md#T-TypeUpdater) - [T_TypeUpdater](typing.md#T-TypeUpdater)
### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater} ### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater}
@ -176,23 +167,19 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数 - **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数
- **参数** - **参数**
- `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数 - `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数
- **返回** - **返回**
- [T_PermissionUpdater](typing.md#T-PermissionUpdater) - [T_PermissionUpdater](typing.md#T-PermissionUpdater)
### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler} ### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler}
- **参数** - **参数**
- `handler` ([T_Handler](typing.md#T-Handler)) - `handler` ([T_Handler](typing.md#T-Handler))
- `parameterless` (Iterable[Any] | None) - `parameterless` (Iterable[Any] | None)
- **返回** - **返回**
- [Dependent](dependencies/index.md#Dependent)[Any] - [Dependent](dependencies/index.md#Dependent)[Any]
### _classmethod_ `handle(parameterless=None)` {#Matcher-handle} ### _classmethod_ `handle(parameterless=None)` {#Matcher-handle}
@ -200,11 +187,9 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数 - **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数
- **参数** - **参数**
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive} ### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive}
@ -212,13 +197,11 @@ description: nonebot.matcher 模块
- **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数 - **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
- **参数** - **参数**
- `id` (str): 消息 ID - `id` (str): 消息 ID
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got} ### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got}
@ -231,7 +214,6 @@ description: nonebot.matcher 模块
如果 `key` 已存在则直接继续运行 如果 `key` 已存在则直接继续运行
- **参数** - **参数**
- `key` (str): 参数名 - `key` (str): 参数名
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息
@ -239,7 +221,6 @@ description: nonebot.matcher 模块
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表 - `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
- **返回** - **返回**
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler) - ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
### _classmethod_ `send(message, **kwargs)` {#Matcher-send} ### _classmethod_ `send(message, **kwargs)` {#Matcher-send}
@ -247,13 +228,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户 - **说明:** 发送一条消息给当前交互用户
- **参数** - **参数**
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容 - `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容
- `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- Any - Any
### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish} ### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish}
@ -261,13 +240,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户并结束当前事件响应器 - **说明:** 发送一条消息给当前交互用户并结束当前事件响应器
- **参数** - **参数**
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause} ### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause}
@ -275,13 +252,11 @@ description: nonebot.matcher 模块
- **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数 - **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
- **参数** - **参数**
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject} ### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject}
@ -289,13 +264,11 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数 - **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
- **参数** - **参数**
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg} ### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg}
@ -303,7 +276,6 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数 - **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数
- **参数** - **参数**
- `key` (str): 参数名 - `key` (str): 参数名
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
@ -311,7 +283,6 @@ description: nonebot.matcher 模块
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive} ### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive}
@ -319,7 +290,6 @@ description: nonebot.matcher 模块
- **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数 - **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
- **参数** - **参数**
- `id` (str): 消息 id - `id` (str): 消息 id
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容 - `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
@ -327,7 +297,6 @@ description: nonebot.matcher 模块
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api - `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
- **返回** - **返回**
- NoReturn - NoReturn
### _classmethod_ `skip()` {#Matcher-skip} ### _classmethod_ `skip()` {#Matcher-skip}
@ -343,7 +312,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- NoReturn - NoReturn
### _method_ `get_receive(id, default=None)` {#Matcher-get-receive} ### _method_ `get_receive(id, default=None)` {#Matcher-get-receive}
@ -357,25 +325,19 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(id) -> Event | None` **1.** `(id) -> Event | None`
- **参数** - **参数**
- `id` (str) - `id` (str)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | None - [Event](adapters/index.md#Event) | None
**2.** `(id, default) -> Event | T` **2.** `(id, default) -> Event | T`
- **参数** - **参数**
- `id` (str) - `id` (str)
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | T - [Event](adapters/index.md#Event) | T
### _method_ `set_receive(id, event)` {#Matcher-set-receive} ### _method_ `set_receive(id, event)` {#Matcher-set-receive}
@ -383,13 +345,11 @@ description: nonebot.matcher 模块
- **说明:** 设置一个 `receive` 事件 - **说明:** 设置一个 `receive` 事件
- **参数** - **参数**
- `id` (str) - `id` (str)
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
- **返回** - **返回**
- None - None
### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive} ### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive}
@ -403,23 +363,18 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `() -> Event | None` **1.** `() -> Event | None`
- **参数** - **参数**
empty empty
- **返回** - **返回**
- [Event](adapters/index.md#Event) | None - [Event](adapters/index.md#Event) | None
**2.** `(default) -> Event | T` **2.** `(default) -> Event | T`
- **参数** - **参数**
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Event](adapters/index.md#Event) | T - [Event](adapters/index.md#Event) | T
### _method_ `get_arg(key, default=None)` {#Matcher-get-arg} ### _method_ `get_arg(key, default=None)` {#Matcher-get-arg}
@ -433,25 +388,19 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(key) -> Message | None` **1.** `(key) -> Message | None`
- **参数** - **参数**
- `key` (str) - `key` (str)
- **返回** - **返回**
- [Message](adapters/index.md#Message) | None - [Message](adapters/index.md#Message) | None
**2.** `(key, default) -> Message | T` **2.** `(key, default) -> Message | T`
- **参数** - **参数**
- `key` (str) - `key` (str)
- `default` (T) - `default` (T)
- **返回** - **返回**
- [Message](adapters/index.md#Message) | T - [Message](adapters/index.md#Message) | T
### _method_ `set_arg(key, message)` {#Matcher-set-arg} ### _method_ `set_arg(key, message)` {#Matcher-set-arg}
@ -459,25 +408,21 @@ description: nonebot.matcher 模块
- **说明:** 设置一个 `got` 消息 - **说明:** 设置一个 `got` 消息
- **参数** - **参数**
- `key` (str) - `key` (str)
- `message` ([Message](adapters/index.md#Message)) - `message` ([Message](adapters/index.md#Message))
- **返回** - **返回**
- None - None
### _method_ `set_target(target, cache=True)` {#Matcher-set-target} ### _method_ `set_target(target, cache=True)` {#Matcher-set-target}
- **参数** - **参数**
- `target` (str) - `target` (str)
- `cache` (bool) - `cache` (bool)
- **返回** - **返回**
- None - None
### _method_ `get_target(default=None)` {#Matcher-get-target} ### _method_ `get_target(default=None)` {#Matcher-get-target}
@ -485,23 +430,18 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `() -> str | None` **1.** `() -> str | None`
- **参数** - **参数**
empty empty
- **返回** - **返回**
- str | None - str | None
**2.** `(default) -> str | T` **2.** `(default) -> str | T`
- **参数** - **参数**
- `default` (T) - `default` (T)
- **返回** - **返回**
- str | T - str | T
### _method_ `stop_propagation()` {#Matcher-stop-propagation} ### _method_ `stop_propagation()` {#Matcher-stop-propagation}
@ -513,13 +453,11 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type} ### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -529,13 +467,11 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- str - str
### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission} ### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -545,7 +481,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- [Permission](permission.md#Permission) - [Permission](permission.md#Permission)
### _async method_ `resolve_reject()` {#Matcher-resolve-reject} ### _async method_ `resolve_reject()` {#Matcher-resolve-reject}
@ -555,25 +490,21 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- untyped - untyped
### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context} ### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
- **返回** - **返回**
- untyped - untyped
### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run} ### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -585,13 +516,11 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- untyped - untyped
### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run} ### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run}
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)) - `bot` ([Bot](adapters/index.md#Bot))
- `event` ([Event](adapters/index.md#Event)) - `event` ([Event](adapters/index.md#Event))
@ -603,7 +532,6 @@ description: nonebot.matcher 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None) - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
- **返回** - **返回**
- untyped - untyped
## _class_ `MatcherManager()` {#MatcherManager} ## _class_ `MatcherManager()` {#MatcherManager}
@ -625,7 +553,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- KeysView[int] - KeysView[int]
### _method_ `values()` {#MatcherManager-values} ### _method_ `values()` {#MatcherManager-values}
@ -635,7 +562,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- ValuesView[list[type[[Matcher](#Matcher)]]] - ValuesView[list[type[[Matcher](#Matcher)]]]
### _method_ `items()` {#MatcherManager-items} ### _method_ `items()` {#MatcherManager-items}
@ -645,7 +571,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- ItemsView[int, list[type[[Matcher](#Matcher)]]] - ItemsView[int, list[type[[Matcher](#Matcher)]]]
### _method_ `get(key, default=None)` {#MatcherManager-get} ### _method_ `get(key, default=None)` {#MatcherManager-get}
@ -653,47 +578,36 @@ description: nonebot.matcher 模块
- **重载** - **重载**
**1.** `(key) -> list[type[Matcher]] | None` **1.** `(key) -> list[type[Matcher]] | None`
- **参数** - **参数**
- `key` (int) - `key` (int)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] | None - list[type[[Matcher](#Matcher)]] | None
**2.** `(key, default) -> list[type[Matcher]]` **2.** `(key, default) -> list[type[Matcher]]`
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (list[type[[Matcher](#Matcher)]]) - `default` (list[type[[Matcher](#Matcher)]])
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
**3.** `(key, default) -> list[type[Matcher]] | T` **3.** `(key, default) -> list[type[Matcher]] | T`
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (T) - `default` (T)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] | T - list[type[[Matcher](#Matcher)]] | T
### _method_ `pop(key)` {#MatcherManager-pop} ### _method_ `pop(key)` {#MatcherManager-pop}
- **参数** - **参数**
- `key` (int) - `key` (int)
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
### _method_ `popitem()` {#MatcherManager-popitem} ### _method_ `popitem()` {#MatcherManager-popitem}
@ -703,7 +617,6 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- tuple[int, list[type[[Matcher](#Matcher)]]] - tuple[int, list[type[[Matcher](#Matcher)]]]
### _method_ `clear()` {#MatcherManager-clear} ### _method_ `clear()` {#MatcherManager-clear}
@ -713,29 +626,24 @@ description: nonebot.matcher 模块
empty empty
- **返回** - **返回**
- None - None
### _method_ `update(m, /)` {#MatcherManager-update} ### _method_ `update(m, /)` {#MatcherManager-update}
- **参数** - **参数**
- `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]]) - `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]])
- **返回** - **返回**
- None - None
### _method_ `setdefault(key, default)` {#MatcherManager-setdefault} ### _method_ `setdefault(key, default)` {#MatcherManager-setdefault}
- **参数** - **参数**
- `key` (int) - `key` (int)
- `default` (list[type[[Matcher](#Matcher)]]) - `default` (list[type[[Matcher](#Matcher)]])
- **返回** - **返回**
- list[type[[Matcher](#Matcher)]] - list[type[[Matcher](#Matcher)]]
### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider} ### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider}
@ -743,11 +651,9 @@ description: nonebot.matcher 模块
- **说明:** 设置事件响应器存储器 - **说明:** 设置事件响应器存储器
- **参数** - **参数**
- `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类 - `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类
- **返回** - **返回**
- None - None
## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider} ## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider}
@ -755,7 +661,6 @@ description: nonebot.matcher 模块
- **说明:** 事件响应器存储器基类 - **说明:** 事件响应器存储器基类
- **参数** - **参数**
- `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器 - `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器
## _var_ `matchers` {#matchers} ## _var_ `matchers` {#matchers}

View File

@ -20,11 +20,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。 装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
- **参数** - **参数**
- `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor)) - `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor))
- **返回** - **返回**
- [T_EventPreProcessor](typing.md#T-EventPreProcessor) - [T_EventPreProcessor](typing.md#T-EventPreProcessor)
## _def_ `event_postprocessor(func)` {#event-postprocessor} ## _def_ `event_postprocessor(func)` {#event-postprocessor}
@ -36,11 +34,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。 装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
- **参数** - **参数**
- `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor)) - `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor))
- **返回** - **返回**
- [T_EventPostProcessor](typing.md#T-EventPostProcessor) - [T_EventPostProcessor](typing.md#T-EventPostProcessor)
## _def_ `run_preprocessor(func)` {#run-preprocessor} ## _def_ `run_preprocessor(func)` {#run-preprocessor}
@ -52,11 +48,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次事件响应器运行前执行。 装饰一个函数,使它在每次事件响应器运行前执行。
- **参数** - **参数**
- `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor)) - `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor))
- **返回** - **返回**
- [T_RunPreProcessor](typing.md#T-RunPreProcessor) - [T_RunPreProcessor](typing.md#T-RunPreProcessor)
## _def_ `run_postprocessor(func)` {#run-postprocessor} ## _def_ `run_postprocessor(func)` {#run-postprocessor}
@ -68,11 +62,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
装饰一个函数,使它在每次事件响应器运行后执行。 装饰一个函数,使它在每次事件响应器运行后执行。
- **参数** - **参数**
- `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor)) - `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor))
- **返回** - **返回**
- [T_RunPostProcessor](typing.md#T-RunPostProcessor) - [T_RunPostProcessor](typing.md#T-RunPostProcessor)
## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher} ## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher}
@ -80,7 +72,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- **说明:** 检查并运行事件响应器。 - **说明:** 检查并运行事件响应器。
- **参数** - **参数**
- `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器 - `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
@ -94,7 +85,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- None - None
## _async def_ `handle_event(bot, event)` {#handle-event} ## _async def_ `handle_event(bot, event)` {#handle-event}
@ -102,13 +92,11 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
- **说明:** 处理一个事件。调用该函数以实现分发事件。 - **说明:** 处理一个事件。调用该函数以实现分发事件。
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
- **返回** - **返回**
- None - None
- **用法** - **用法**

View File

@ -14,11 +14,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息 - **说明:** Arg 参数消息
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- Any - Any
## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam} ## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam}
@ -33,7 +31,6 @@ description: nonebot.params 模块
留空则会根据参数名称获取。 留空则会根据参数名称获取。
- **参数** - **参数**
- `*args` - `*args`
- `key` (str) - `key` (str)
@ -47,11 +44,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息纯文本 - **说明:** Arg 参数消息纯文本
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- str - str
## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult} ## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult}
@ -59,11 +54,9 @@ description: nonebot.params 模块
- **说明:** `arg` prompt 发送结果 - **说明:** `arg` prompt 发送结果
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- Any - Any
## _def_ `ArgStr(key=None)` {#ArgStr} ## _def_ `ArgStr(key=None)` {#ArgStr}
@ -71,11 +64,9 @@ description: nonebot.params 模块
- **说明:** Arg 参数消息文本 - **说明:** Arg 参数消息文本
- **参数** - **参数**
- `key` (str | None) - `key` (str | None)
- **返回** - **返回**
- str - str
## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam} ## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam}
@ -89,7 +80,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -107,7 +97,6 @@ description: nonebot.params 模块
本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。 本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -125,7 +114,6 @@ description: nonebot.params 模块
本注入应该具有最高优先级,因此应该在其他参数之前检查。 本注入应该具有最高优先级,因此应该在其他参数之前检查。
- **参数** - **参数**
- `*args` - `*args`
- `dependent` ([Dependent](dependencies/index.md#Dependent)[Any]) - `dependent` ([Dependent](dependencies/index.md#Dependent)[Any])
@ -139,7 +127,6 @@ description: nonebot.params 模块
- **说明:** 子依赖装饰器 - **说明:** 子依赖装饰器
- **参数** - **参数**
- `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。 - `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。
- `use_cache` (bool): 是否使用缓存。默认为 `True` - `use_cache` (bool): 是否使用缓存。默认为 `True`
@ -147,7 +134,6 @@ description: nonebot.params 模块
- `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False` - `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False`
- **返回** - **返回**
- Any - Any
- **用法** - **用法**
@ -180,7 +166,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -198,7 +183,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -216,7 +200,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `checker` ([ModelField](compat.md#ModelField) | None) - `checker` ([ModelField](compat.md#ModelField) | None)
@ -234,7 +217,6 @@ description: nonebot.params 模块
为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。 为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。
- **参数** - **参数**
- `*args` - `*args`
- `validate` (bool) - `validate` (bool)
@ -250,7 +232,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `EventMessage()` {#EventMessage} ## _def_ `EventMessage()` {#EventMessage}
@ -262,7 +243,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `EventPlainText()` {#EventPlainText} ## _def_ `EventPlainText()` {#EventPlainText}
@ -274,7 +254,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `EventToMe()` {#EventToMe} ## _def_ `EventToMe()` {#EventToMe}
@ -286,7 +265,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- bool - bool
## _def_ `Command()` {#Command} ## _def_ `Command()` {#Command}
@ -298,7 +276,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- tuple[str, ...] - tuple[str, ...]
## _def_ `RawCommand()` {#RawCommand} ## _def_ `RawCommand()` {#RawCommand}
@ -310,7 +287,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `CommandArg()` {#CommandArg} ## _def_ `CommandArg()` {#CommandArg}
@ -322,7 +298,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `CommandStart()` {#CommandStart} ## _def_ `CommandStart()` {#CommandStart}
@ -334,7 +309,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `CommandWhitespace()` {#CommandWhitespace} ## _def_ `CommandWhitespace()` {#CommandWhitespace}
@ -346,7 +320,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `ShellCommandArgs()` {#ShellCommandArgs} ## _def_ `ShellCommandArgs()` {#ShellCommandArgs}
@ -358,7 +331,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `ShellCommandArgv()` {#ShellCommandArgv} ## _def_ `ShellCommandArgv()` {#ShellCommandArgv}
@ -370,7 +342,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any
## _def_ `RegexMatched()` {#RegexMatched} ## _def_ `RegexMatched()` {#RegexMatched}
@ -382,7 +353,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Match[str] - Match[str]
## _def_ `RegexStr(*groups)` {#RegexStr} ## _def_ `RegexStr(*groups)` {#RegexStr}
@ -392,29 +362,21 @@ description: nonebot.params 模块
- **重载** - **重载**
**1.** `(group, /) -> str` **1.** `(group, /) -> str`
- **参数** - **参数**
- `group` (Literal[0]) - `group` (Literal[0])
- **返回** - **返回**
- str - str
**2.** `(group, /) -> str | Any` **2.** `(group, /) -> str | Any`
- **参数** - **参数**
- `group` (str | int) - `group` (str | int)
- **返回** - **返回**
- str | Any - str | Any
**3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]` **3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]`
- **参数** - **参数**
- `group1` (str | int) - `group1` (str | int)
- `group2` (str | int) - `group2` (str | int)
@ -422,7 +384,6 @@ description: nonebot.params 模块
- `*groups` (str | int) - `*groups` (str | int)
- **返回** - **返回**
- tuple[str | Any, ...] - tuple[str | Any, ...]
## _def_ `RegexGroup()` {#RegexGroup} ## _def_ `RegexGroup()` {#RegexGroup}
@ -434,7 +395,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- tuple[Any, ...] - tuple[Any, ...]
## _def_ `RegexDict()` {#RegexDict} ## _def_ `RegexDict()` {#RegexDict}
@ -446,7 +406,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- dict[str, Any] - dict[str, Any]
## _def_ `Startswith()` {#Startswith} ## _def_ `Startswith()` {#Startswith}
@ -458,7 +417,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Endswith()` {#Endswith} ## _def_ `Endswith()` {#Endswith}
@ -470,7 +428,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Fullmatch()` {#Fullmatch} ## _def_ `Fullmatch()` {#Fullmatch}
@ -482,7 +439,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Keyword()` {#Keyword} ## _def_ `Keyword()` {#Keyword}
@ -494,7 +450,6 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- str - str
## _def_ `Received(id=None, default=None)` {#Received} ## _def_ `Received(id=None, default=None)` {#Received}
@ -502,13 +457,11 @@ description: nonebot.params 模块
- **说明:** `receive` 事件参数 - **说明:** `receive` 事件参数
- **参数** - **参数**
- `id` (str | None) - `id` (str | None)
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `LastReceived(default=None)` {#LastReceived} ## _def_ `LastReceived(default=None)` {#LastReceived}
@ -516,11 +469,9 @@ description: nonebot.params 模块
- **说明:** `last_receive` 事件参数 - **说明:** `last_receive` 事件参数
- **参数** - **参数**
- `default` (Any) - `default` (Any)
- **返回** - **返回**
- Any - Any
## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult} ## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult}
@ -528,11 +479,9 @@ description: nonebot.params 模块
- **说明:** `receive` prompt 发送结果 - **说明:** `receive` prompt 发送结果
- **参数** - **参数**
- `id` (str | None) - `id` (str | None)
- **返回** - **返回**
- Any - Any
## _def_ `PausePromptResult()` {#PausePromptResult} ## _def_ `PausePromptResult()` {#PausePromptResult}
@ -544,5 +493,4 @@ description: nonebot.params 模块
empty empty
- **返回** - **返回**
- Any - Any

View File

@ -22,7 +22,6 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。
- **参数** - **参数**
- `*users` (str) - `*users` (str)
- `perm` (Permission | None): 需要同时满足的权限 - `perm` (Permission | None): 需要同时满足的权限
@ -30,7 +29,6 @@ description: nonebot.permission 模块
- `user`: 会话白名单 - `user`: 会话白名单
- **返回** - **返回**
- untyped - untyped
## _class_ `Permission(*checkers)` {#Permission} ## _class_ `Permission(*checkers)` {#Permission}
@ -42,7 +40,6 @@ description: nonebot.permission 模块
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。 当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
- **参数** - **参数**
- `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker - `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker
- **用法** - **用法**
@ -64,7 +61,6 @@ description: nonebot.permission 模块
- **说明:** 检查是否满足某个权限。 - **说明:** 检查是否满足某个权限。
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
@ -74,7 +70,6 @@ description: nonebot.permission 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool - bool
## _class_ `User(users, perm=None)` {#User} ## _class_ `User(users, perm=None)` {#User}
@ -82,7 +77,6 @@ description: nonebot.permission 模块
- **说明:** 检查当前事件是否属于指定会话。 - **说明:** 检查当前事件是否属于指定会话。
- **参数** - **参数**
- `users` (tuple[str, ...]): 会话 ID 元组 - `users` (tuple[str, ...]): 会话 ID 元组
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
@ -96,13 +90,11 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
- **参数** - **参数**
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
- **返回** - **返回**
- Self - Self
### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission} ### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission}
@ -114,13 +106,11 @@ description: nonebot.permission 模块
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。 如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
- **参数** - **参数**
- `*users` (str): 会话白名单 - `*users` (str): 会话白名单
- `perm` (Permission | None): 需同时满足的权限 - `perm` (Permission | None): 需同时满足的权限
- **返回** - **返回**
- Self - Self
## _class_ `Message(<auto>)` {#Message} ## _class_ `Message(<auto>)` {#Message}

View File

@ -51,11 +51,9 @@ description: nonebot.plugin 模块
如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名` 如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名`
- **参数** - **参数**
- `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。 - `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name} ## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name}
@ -67,11 +65,9 @@ description: nonebot.plugin 模块
如果提供的模块名为某个插件的子模块,同样会返回该插件。 如果提供的模块名为某个插件的子模块,同样会返回该插件。
- **参数** - **参数**
- `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。 - `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_loaded_plugins()` {#get-loaded-plugins} ## _def_ `get_loaded_plugins()` {#get-loaded-plugins}
@ -83,7 +79,6 @@ description: nonebot.plugin 模块
empty empty
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `get_available_plugin_names()` {#get-available-plugin-names} ## _def_ `get_available_plugin_names()` {#get-available-plugin-names}
@ -95,7 +90,6 @@ description: nonebot.plugin 模块
empty empty
- **返回** - **返回**
- set[str] - set[str]
## _def_ `get_plugin_config(config)` {#get-plugin-config} ## _def_ `get_plugin_config(config)` {#get-plugin-config}
@ -103,9 +97,7 @@ description: nonebot.plugin 模块
- **说明:** 从全局配置获取当前插件需要的配置项。 - **说明:** 从全局配置获取当前插件需要的配置项。
- **参数** - **参数**
- `config` (type[C]) - `config` (type[C])
- **返回** - **返回**
- C - C

View File

@ -14,11 +14,9 @@ description: nonebot.plugin.load 模块
- **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。 - **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。
- **参数** - **参数**
- `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)` - `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)`
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `load_plugins(*plugin_dir)` {#load-plugins} ## _def_ `load_plugins(*plugin_dir)` {#load-plugins}
@ -26,11 +24,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入! - **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `*plugin_dir` (str): 文件夹路径 - `*plugin_dir` (str): 文件夹路径
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins} ## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins}
@ -38,13 +34,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入! - **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `module_path` (Iterable[str]): 指定插件集合 - `module_path` (Iterable[str]): 指定插件集合
- `plugin_dir` (Iterable[str]): 指定文件夹路径集合 - `plugin_dir` (Iterable[str]): 指定文件夹路径集合
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json} ## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json}
@ -52,13 +46,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入! - **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `file_path` (str): 指定 json 文件路径 - `file_path` (str): 指定 json 文件路径
- `encoding` (str): 指定 json 文件编码 - `encoding` (str): 指定 json 文件编码
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
- **用法** - **用法**
@ -79,13 +71,11 @@ description: nonebot.plugin.load 模块
- **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入! - **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
- **参数** - **参数**
- `file_path` (str): 指定 toml 文件路径 - `file_path` (str): 指定 toml 文件路径
- `encoding` (str): 指定 toml 文件编码 - `encoding` (str): 指定 toml 文件编码
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
- **用法** - **用法**
@ -105,11 +95,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入 NoneBot 内置插件。 - **说明:** 导入 NoneBot 内置插件。
- **参数** - **参数**
- `name` (str): 插件名称 - `name` (str): 插件名称
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins} ## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins}
@ -117,11 +105,9 @@ description: nonebot.plugin.load 模块
- **说明:** 导入多个 NoneBot 内置插件。 - **说明:** 导入多个 NoneBot 内置插件。
- **参数** - **参数**
- `*plugins` (str): 插件名称列表 - `*plugins` (str): 插件名称列表
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _def_ `require(name)` {#require} ## _def_ `require(name)` {#require}
@ -129,15 +115,12 @@ description: nonebot.plugin.load 模块
- **说明:** 声明依赖插件。 - **说明:** 声明依赖插件。
- **参数** - **参数**
- `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。 - `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。
- **返回** - **返回**
- ModuleType - ModuleType
- **异常** - **异常**
- RuntimeError: 插件无法加载 - RuntimeError: 插件无法加载
## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters} ## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters}
@ -149,15 +132,12 @@ description: nonebot.plugin.load 模块
如果传入了多个插件名称,返回值会自动取交集。 如果传入了多个插件名称,返回值会自动取交集。
- **参数** - **参数**
- `*names` (str): 插件名称列表。 - `*names` (str): 插件名称列表。
- **返回** - **返回**
- set[str] | None - set[str] | None
- **异常** - **异常**
- RuntimeError: 插件未加载 - RuntimeError: 插件未加载
- ValueError: 插件缺少元数据 - ValueError: 插件缺少元数据

View File

@ -16,7 +16,6 @@ description: nonebot.plugin.manager 模块
- **说明:** 插件管理器。 - **说明:** 插件管理器。
- **参数** - **参数**
- `plugins` (Iterable[str] | None): 独立插件模块名集合。 - `plugins` (Iterable[str] | None): 独立插件模块名集合。
- `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。 - `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。
@ -54,11 +53,9 @@ description: nonebot.plugin.manager 模块
可以使用完整插件模块名或者插件标识符加载。 可以使用完整插件模块名或者插件标识符加载。
- **参数** - **参数**
- `name` (str): 插件名称或插件标识符。 - `name` (str): 插件名称或插件标识符。
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins} ### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins}
@ -70,7 +67,6 @@ description: nonebot.plugin.manager 模块
empty empty
- **返回** - **返回**
- set[[Plugin](model.md#Plugin)] - set[[Plugin](model.md#Plugin)]
## _class_ `PluginFinder(<auto>)` {#PluginFinder} ## _class_ `PluginFinder(<auto>)` {#PluginFinder}
@ -82,7 +78,6 @@ description: nonebot.plugin.manager 模块
### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec} ### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec}
- **参数** - **参数**
- `fullname` (str) - `fullname` (str)
- `path` (Sequence[str] | None) - `path` (Sequence[str] | None)
@ -90,13 +85,11 @@ description: nonebot.plugin.manager 模块
- `target` (ModuleType | None) - `target` (ModuleType | None)
- **返回** - **返回**
- untyped - untyped
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader} ## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
- **参数** - **参数**
- `manager` (PluginManager) - `manager` (PluginManager)
- `fullname` (str) - `fullname` (str)
@ -106,19 +99,15 @@ description: nonebot.plugin.manager 模块
### _method_ `create_module(spec)` {#PluginLoader-create-module} ### _method_ `create_module(spec)` {#PluginLoader-create-module}
- **参数** - **参数**
- `spec` - `spec`
- **返回** - **返回**
- ModuleType | None - ModuleType | None
### _method_ `exec_module(module)` {#PluginLoader-exec-module} ### _method_ `exec_module(module)` {#PluginLoader-exec-module}
- **参数** - **参数**
- `module` (ModuleType) - `module` (ModuleType)
- **返回** - **返回**
- None - None

View File

@ -80,7 +80,6 @@ description: nonebot.plugin.model 模块
empty empty
- **返回** - **返回**
- set[type[[Adapter](../adapters/index.md#Adapter)]] | None - set[type[[Adapter](../adapters/index.md#Adapter)]] | None
## _class_ `Plugin(<auto>)` {#Plugin} ## _class_ `Plugin(<auto>)` {#Plugin}

View File

@ -14,11 +14,9 @@ description: nonebot.plugin.on 模块
- **说明:** 存储一个事件响应器到插件。 - **说明:** 存储一个事件响应器到插件。
- **参数** - **参数**
- `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器 - `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器
- **返回** - **返回**
- None - None
## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin} ## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin}
@ -30,11 +28,9 @@ description: nonebot.plugin.on 模块
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。 **Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- [Plugin](model.md#Plugin) | None - [Plugin](model.md#Plugin) | None
## _def_ `get_matcher_module(depth=...)` {#get-matcher-module} ## _def_ `get_matcher_module(depth=...)` {#get-matcher-module}
@ -46,11 +42,9 @@ description: nonebot.plugin.on 模块
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。 **Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- ModuleType | None - ModuleType | None
## _def_ `get_matcher_source(depth=...)` {#get-matcher-source} ## _def_ `get_matcher_source(depth=...)` {#get-matcher-source}
@ -58,11 +52,9 @@ description: nonebot.plugin.on 模块
- **说明:** 获取事件响应器定义所在源码信息。 - **说明:** 获取事件响应器定义所在源码信息。
- **参数** - **参数**
- `depth` (int): 调用栈深度 - `depth` (int): 调用栈深度
- **返回** - **返回**
- MatcherSource | None - MatcherSource | None
## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on} ## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on}
@ -70,7 +62,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个基础事件响应器,可自定义类型。 - **说明:** 注册一个基础事件响应器,可自定义类型。
- **参数** - **参数**
- `type` (str): 事件响应器类型 - `type` (str): 事件响应器类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -90,7 +81,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent} ## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent}
@ -98,7 +88,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个元事件响应器。 - **说明:** 注册一个元事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -116,7 +105,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message} ## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message}
@ -124,7 +112,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器。 - **说明:** 注册一个消息事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -142,7 +129,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice} ## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice}
@ -150,7 +136,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个通知事件响应器。 - **说明:** 注册一个通知事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -168,7 +153,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request} ## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request}
@ -176,7 +160,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个请求事件响应器。 - **说明:** 注册一个请求事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -194,7 +177,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith} ## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith}
@ -202,7 +184,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头内容 - `msg` (str | tuple[str, ...]): 指定消息开头内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -224,7 +205,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith} ## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith}
@ -232,7 +212,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息结尾内容 - `msg` (str | tuple[str, ...]): 指定消息结尾内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -254,7 +233,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch} ## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch}
@ -262,7 +240,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容 - `msg` (str | tuple[str, ...]): 指定消息全匹配内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -284,7 +261,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword} ## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword}
@ -292,7 +268,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。 - **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
- **参数** - **参数**
- `keywords` (set[str]): 关键词列表 - `keywords` (set[str]): 关键词列表
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -312,7 +287,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command} ## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command}
@ -324,7 +298,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_ 命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -348,7 +321,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command} ## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command}
@ -363,7 +335,6 @@ description: nonebot.plugin.on 模块
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。 通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -387,7 +358,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex} ## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex}
@ -399,7 +369,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_ 命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
- **参数** - **参数**
- `pattern` (str): 正则表达式 - `pattern` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则匹配标志 - `flags` (int | re.RegexFlag): 正则匹配标志
@ -421,7 +390,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type} ## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type}
@ -429,7 +397,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。 - **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
- **参数** - **参数**
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型 - `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -449,13 +416,11 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup} ## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup}
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]) - `cmd` (str | tuple[str, ...])
- `prefix_aliases` (bool) - `prefix_aliases` (bool)
@ -481,7 +446,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值 - **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -505,7 +469,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command} ### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command}
@ -513,7 +476,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值 - **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -537,13 +499,11 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup} ## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup}
- **参数** - **参数**
- `type` (str) - `type` (str)
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None) - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None)
@ -567,7 +527,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个基础事件响应器,可自定义类型。 - **说明:** 注册一个基础事件响应器,可自定义类型。
- **参数** - **参数**
- `type` (str): 事件响应器类型 - `type` (str): 事件响应器类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -587,7 +546,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent} ### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent}
@ -595,7 +553,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个元事件响应器。 - **说明:** 注册一个元事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -613,7 +570,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message} ### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message}
@ -621,7 +577,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器。 - **说明:** 注册一个消息事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -639,7 +594,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice} ### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice}
@ -647,7 +601,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个通知事件响应器。 - **说明:** 注册一个通知事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -665,7 +618,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request} ### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request}
@ -673,7 +625,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个请求事件响应器。 - **说明:** 注册一个请求事件响应器。
- **参数** - **参数**
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限 - `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
@ -691,7 +642,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith} ### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith}
@ -699,7 +649,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头内容 - `msg` (str | tuple[str, ...]): 指定消息开头内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -721,7 +670,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith} ### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith}
@ -729,7 +677,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息结尾内容 - `msg` (str | tuple[str, ...]): 指定消息结尾内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -751,7 +698,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch} ### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch}
@ -759,7 +705,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。 - **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容 - `msg` (str | tuple[str, ...]): 指定消息全匹配内容
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -781,7 +726,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword} ### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword}
@ -789,7 +733,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。 - **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
- **参数** - **参数**
- `keywords` (set[str]): 关键词列表 - `keywords` (set[str]): 关键词列表
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -809,7 +752,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command} ### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command}
@ -821,7 +763,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_ 命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名 - `aliases` (set[str | tuple[str, ...]] | None): 命令别名
@ -845,7 +786,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command} ### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command}
@ -860,7 +800,6 @@ description: nonebot.plugin.on 模块
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。 通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
- **参数** - **参数**
- `cmd` (str | tuple[str, ...]): 指定命令内容 - `cmd` (str | tuple[str, ...]): 指定命令内容
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名 - `aliases` (set[str | tuple[str, ...]] | None): 命令别名
@ -884,7 +823,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex} ### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex}
@ -896,7 +834,6 @@ description: nonebot.plugin.on 模块
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_ 命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
- **参数** - **参数**
- `pattern` (str): 正则表达式 - `pattern` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则匹配标志 - `flags` (int | re.RegexFlag): 正则匹配标志
@ -918,7 +855,6 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]
### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type} ### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type}
@ -926,7 +862,6 @@ description: nonebot.plugin.on 模块
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。 - **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
- **参数** - **参数**
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型 - `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则 - `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
@ -946,5 +881,4 @@ description: nonebot.plugin.on 模块
- `state` ([T_State](../typing.md#T-State) | None): 默认 state - `state` ([T_State](../typing.md#T-State) | None): 默认 state
- **返回** - **返回**
- type[[Matcher](../matcher.md#Matcher)] - type[[Matcher](../matcher.md#Matcher)]

View File

@ -22,7 +22,6 @@ description: nonebot.rule 模块
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。 当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
- **参数** - **参数**
- `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker - `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker
- **用法** - **用法**
@ -44,7 +43,6 @@ description: nonebot.rule 模块
- **说明:** 检查是否符合所有规则 - **说明:** 检查是否符合所有规则
- **参数** - **参数**
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象 - `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
- `event` ([Event](adapters/index.md#Event)): Event 对象 - `event` ([Event](adapters/index.md#Event)): Event 对象
@ -56,7 +54,6 @@ description: nonebot.rule 模块
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存 - `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
- **返回** - **返回**
- bool - bool
## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT} ## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT}
@ -78,7 +75,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否以指定字符串开头。 - **说明:** 检查消息纯文本是否以指定字符串开头。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息开头字符串元组 - `msg` (tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -88,13 +84,11 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本开头。 - **说明:** 匹配消息纯文本开头。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组 - `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule} ## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule}
@ -102,7 +96,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否以指定字符串结尾。 - **说明:** 检查消息纯文本是否以指定字符串结尾。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息结尾字符串元组 - `msg` (tuple[str, ...]): 指定消息结尾字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -112,13 +105,11 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本结尾。 - **说明:** 匹配消息纯文本结尾。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组 - `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule} ## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule}
@ -126,7 +117,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否与指定字符串全匹配。 - **说明:** 检查消息纯文本是否与指定字符串全匹配。
- **参数** - **参数**
- `msg` (tuple[str, ...]): 指定消息全匹配字符串元组 - `msg` (tuple[str, ...]): 指定消息全匹配字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
@ -136,13 +126,11 @@ description: nonebot.rule 模块
- **说明:** 完全匹配消息。 - **说明:** 完全匹配消息。
- **参数** - **参数**
- `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组 - `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组
- `ignorecase` (bool): 是否忽略大小写 - `ignorecase` (bool): 是否忽略大小写
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `KeywordsRule(*keywords)` {#KeywordsRule} ## _class_ `KeywordsRule(*keywords)` {#KeywordsRule}
@ -150,7 +138,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息纯文本是否包含指定关键字。 - **说明:** 检查消息纯文本是否包含指定关键字。
- **参数** - **参数**
- `*keywords` (str): 指定关键字元组 - `*keywords` (str): 指定关键字元组
## _def_ `keyword(*keywords)` {#keyword} ## _def_ `keyword(*keywords)` {#keyword}
@ -158,11 +145,9 @@ description: nonebot.rule 模块
- **说明:** 匹配消息纯文本关键词。 - **说明:** 匹配消息纯文本关键词。
- **参数** - **参数**
- `*keywords` (str): 指定关键字元组 - `*keywords` (str): 指定关键字元组
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule} ## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule}
@ -170,7 +155,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息是否为指定命令。 - **说明:** 检查消息是否为指定命令。
- **参数** - **参数**
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表 - `cmds` (list[tuple[str, ...]]): 指定命令元组列表
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符 - `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
@ -189,13 +173,11 @@ description: nonebot.rule 模块
通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。 通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。
- **参数** - **参数**
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组 - `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符 - `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
- **用法** - **用法**
@ -231,37 +213,28 @@ description: nonebot.rule 模块
- **重载** - **重载**
**1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]` **1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]`
- **参数** - **参数**
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None) - `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
- `namespace` (None) - `namespace` (None)
- **返回** - **返回**
- tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
**2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]` **2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]`
- **参数** - **参数**
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None) - `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
- `namespace` (T) - `namespace` (T)
- **返回** - **返回**
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
**3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]` **3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]`
- **参数** - **参数**
- `namespace` (T) - `namespace` (T)
- **返回** - **返回**
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]] - tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule} ## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule}
@ -269,7 +242,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息是否为指定 shell 命令。 - **说明:** 检查消息是否为指定 shell 命令。
- **参数** - **参数**
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表 - `cmds` (list[tuple[str, ...]]): 指定命令元组列表
- `parser` (ArgumentParser | None): 可选参数解析器 - `parser` (ArgumentParser | None): 可选参数解析器
@ -298,13 +270,11 @@ description: nonebot.rule 模块
::: :::
- **参数** - **参数**
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组 - `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
- `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象 - `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
- **用法** - **用法**
@ -330,7 +300,6 @@ description: nonebot.rule 模块
- **说明:** 检查消息字符串是否符合指定正则表达式。 - **说明:** 检查消息字符串是否符合指定正则表达式。
- **参数** - **参数**
- `regex` (str): 正则表达式 - `regex` (str): 正则表达式
- `flags` (int): 正则表达式标记 - `flags` (int): 正则表达式标记
@ -346,13 +315,11 @@ description: nonebot.rule 模块
通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。 通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。
- **参数** - **参数**
- `regex` (str): 正则表达式 - `regex` (str): 正则表达式
- `flags` (int | re.RegexFlag): 正则表达式标记 - `flags` (int | re.RegexFlag): 正则表达式标记
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
:::tip 提示 :::tip 提示
@ -380,7 +347,6 @@ description: nonebot.rule 模块
empty empty
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)
## _class_ `IsTypeRule(*types)` {#IsTypeRule} ## _class_ `IsTypeRule(*types)` {#IsTypeRule}
@ -388,7 +354,6 @@ description: nonebot.rule 模块
- **说明:** 检查事件类型是否为指定类型。 - **说明:** 检查事件类型是否为指定类型。
- **参数** - **参数**
- `*types` (type[[Event](adapters/index.md#Event)]) - `*types` (type[[Event](adapters/index.md#Event)])
## _def_ `is_type(*types)` {#is-type} ## _def_ `is_type(*types)` {#is-type}
@ -396,9 +361,7 @@ description: nonebot.rule 模块
- **说明:** 匹配事件类型。 - **说明:** 匹配事件类型。
- **参数** - **参数**
- `*types` (type[[Event](adapters/index.md#Event)]): 事件类型 - `*types` (type[[Event](adapters/index.md#Event)]): 事件类型
- **返回** - **返回**
- [Rule](#Rule) - [Rule](#Rule)

View File

@ -19,31 +19,25 @@ description: nonebot.typing 模块
- **说明:** 标记一个方法为父类 interface 的 implement - **说明:** 标记一个方法为父类 interface 的 implement
- **参数** - **参数**
- `InterfaceClass` (object) - `InterfaceClass` (object)
- **返回** - **返回**
- untyped - untyped
## _def_ `type_has_args(type_)` {#type-has-args} ## _def_ `type_has_args(type_)` {#type-has-args}
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `origin_is_union(origin)` {#origin-is-union} ## _def_ `origin_is_union(origin)` {#origin-is-union}
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `origin_is_literal(origin)` {#origin-is-literal} ## _def_ `origin_is_literal(origin)` {#origin-is-literal}
@ -51,11 +45,9 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 Literal 类型 - **说明:** 判断是否是 Literal 类型
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `all_literal_values(type_)` {#all-literal-values} ## _def_ `all_literal_values(type_)` {#all-literal-values}
@ -63,11 +55,9 @@ description: nonebot.typing 模块
- **说明:** 获取 Literal 类型包含的所有值 - **说明:** 获取 Literal 类型包含的所有值
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- list[Any] - list[Any]
## _def_ `origin_is_annotated(origin)` {#origin-is-annotated} ## _def_ `origin_is_annotated(origin)` {#origin-is-annotated}
@ -75,11 +65,9 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 Annotated 类型 - **说明:** 判断是否是 Annotated 类型
- **参数** - **参数**
- `origin` (type[Any] | None) - `origin` (type[Any] | None)
- **返回** - **返回**
- bool - bool
## _def_ `is_none_type(type_)` {#is-none-type} ## _def_ `is_none_type(type_)` {#is-none-type}
@ -87,27 +75,22 @@ description: nonebot.typing 模块
- **说明:** 判断是否是 None 类型 - **说明:** 判断是否是 None 类型
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `is_type_alias_type(type_)` {#is-type-alias-type} ## _def_ `is_type_alias_type(type_)` {#is-type-alias-type}
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref} ## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref}
- **参数** - **参数**
- `ref` (ForwardRef) - `ref` (ForwardRef)
- `globalns` (dict[str, Any]) - `globalns` (dict[str, Any])
@ -115,7 +98,6 @@ description: nonebot.typing 模块
- `localns` (dict[str, Any]) - `localns` (dict[str, Any])
- **返回** - **返回**
- Any - Any
## _class_ `StateFlag(<auto>)` {#StateFlag} ## _class_ `StateFlag(<auto>)` {#StateFlag}
@ -139,7 +121,6 @@ description: nonebot.typing 模块
Bot 连接建立时钩子函数 Bot 连接建立时钩子函数
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- DefaultParam: 带有默认值的参数 - DefaultParam: 带有默认值的参数
@ -153,7 +134,6 @@ description: nonebot.typing 模块
Bot 连接断开时钩子函数 Bot 连接断开时钩子函数
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- DefaultParam: 带有默认值的参数 - DefaultParam: 带有默认值的参数
@ -179,7 +159,6 @@ description: nonebot.typing 模块
事件预处理函数 EventPreProcessor 类型 事件预处理函数 EventPreProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -195,7 +174,6 @@ description: nonebot.typing 模块
事件后处理函数 EventPostProcessor 类型 事件后处理函数 EventPostProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -211,7 +189,6 @@ description: nonebot.typing 模块
事件响应器运行前预处理函数 RunPreProcessor 类型 事件响应器运行前预处理函数 RunPreProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -228,7 +205,6 @@ description: nonebot.typing 模块
事件响应器运行后后处理函数 RunPostProcessor 类型 事件响应器运行后后处理函数 RunPostProcessor 类型
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -246,7 +222,6 @@ description: nonebot.typing 模块
RuleChecker 即判断是否响应事件的处理函数。 RuleChecker 即判断是否响应事件的处理函数。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -262,7 +237,6 @@ description: nonebot.typing 模块
PermissionChecker 即判断事件是否满足权限的处理函数。 PermissionChecker 即判断事件是否满足权限的处理函数。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -283,7 +257,6 @@ description: nonebot.typing 模块
TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message` TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message`
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象
@ -300,7 +273,6 @@ description: nonebot.typing 模块
PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。 PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。
依赖参数: 依赖参数:
- DependParam: 子依赖参数 - DependParam: 子依赖参数
- BotParam: Bot 对象 - BotParam: Bot 对象
- EventParam: Event 对象 - EventParam: Event 对象

View File

@ -18,11 +18,9 @@ description: nonebot.utils 模块
参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color) 参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color)
- **参数** - **参数**
- `s` (str): 需要转义的字符串 - `s` (str): 需要转义的字符串
- **返回** - **返回**
- str - str
## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update} ## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update}
@ -30,13 +28,11 @@ description: nonebot.utils 模块
- **说明:** 深度更新合并字典 - **说明:** 深度更新合并字典
- **参数** - **参数**
- `mapping` (dict[K, Any]) - `mapping` (dict[K, Any])
- `*updating_mappings` (dict[K, Any]) - `*updating_mappings` (dict[K, Any])
- **返回** - **返回**
- dict[K, Any] - dict[K, Any]
## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass} ## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass}
@ -44,13 +40,11 @@ description: nonebot.utils 模块
- **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。 - **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。
- **参数** - **参数**
- `cls` (Any) - `cls` (Any)
- `class_or_tuple` (type[Any] | tuple[type[Any], ...]) - `class_or_tuple` (type[Any] | tuple[type[Any], ...])
- **返回** - **返回**
- bool - bool
## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass} ## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass}
@ -60,7 +54,6 @@ description: nonebot.utils 模块
检查 cls 是否是 class_or_tuple 中的一个类型子类。 检查 cls 是否是 class_or_tuple 中的一个类型子类。
特别的: 特别的:
- 如果 cls 是 `typing.TypeVar` 类型, - 如果 cls 是 `typing.TypeVar` 类型,
则会检查其 `__bound__``__constraints__` 则会检查其 `__bound__``__constraints__`
是否是 class_or_tuple 中一个类型的子类或 None。 是否是 class_or_tuple 中一个类型的子类或 None。
@ -72,13 +65,11 @@ description: nonebot.utils 模块
则会检查其原始类型是否是 class_or_tuple 中一个类型的子类。 则会检查其原始类型是否是 class_or_tuple 中一个类型的子类。
- **参数** - **参数**
- `cls` (Any) - `cls` (Any)
- `class_or_tuple` (type[Any] | tuple[type[Any], ...]) - `class_or_tuple` (type[Any] | tuple[type[Any], ...])
- **返回** - **返回**
- bool - bool
## _def_ `type_is_complex(type_)` {#type-is-complex} ## _def_ `type_is_complex(type_)` {#type-is-complex}
@ -86,11 +77,9 @@ description: nonebot.utils 模块
- **说明:** 检查 type\_ 是否是复杂类型 - **说明:** 检查 type\_ 是否是复杂类型
- **参数** - **参数**
- `type_` (type[Any]) - `type_` (type[Any])
- **返回** - **返回**
- bool - bool
## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable} ## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable}
@ -98,11 +87,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个 callable 协程函数 - **说明:** 检查 call 是否是一个 callable 协程函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `is_gen_callable(call)` {#is-gen-callable} ## _def_ `is_gen_callable(call)` {#is-gen-callable}
@ -110,11 +97,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个生成器函数 - **说明:** 检查 call 是否是一个生成器函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable} ## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable}
@ -122,11 +107,9 @@ description: nonebot.utils 模块
- **说明:** 检查 call 是否是一个异步生成器函数 - **说明:** 检查 call 是否是一个异步生成器函数
- **参数** - **参数**
- `call` ((...) -> Any) - `call` ((...) -> Any)
- **返回** - **返回**
- bool - bool
## _def_ `run_sync(call)` {#run-sync} ## _def_ `run_sync(call)` {#run-sync}
@ -134,11 +117,9 @@ description: nonebot.utils 模块
- **说明:** 一个用于包装 sync function 为 async function 的装饰器 - **说明:** 一个用于包装 sync function 为 async function 的装饰器
- **参数** - **参数**
- `call` ((P) -> R): 被装饰的同步函数 - `call` ((P) -> R): 被装饰的同步函数
- **返回** - **返回**
- (P) -> Coroutine[None, None, R] - (P) -> Coroutine[None, None, R]
## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager} ## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager}
@ -146,11 +127,9 @@ description: nonebot.utils 模块
- **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数 - **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数
- **参数** - **参数**
- `cm` (AbstractContextManager[T]) - `cm` (AbstractContextManager[T])
- **返回** - **返回**
- AsyncGenerator[T, None] - AsyncGenerator[T, None]
## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch} ## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch}
@ -160,9 +139,7 @@ description: nonebot.utils 模块
- **重载** - **重载**
**1.** `(coro, exc, return_on_err=None) -> T | None` **1.** `(coro, exc, return_on_err=None) -> T | None`
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]) - `coro` (Coroutine[Any, Any, T])
- `exc` (tuple[type[Exception], ...]) - `exc` (tuple[type[Exception], ...])
@ -170,13 +147,10 @@ description: nonebot.utils 模块
- `return_on_err` (None) - `return_on_err` (None)
- **返回** - **返回**
- T | None - T | None
**2.** `(coro, exc, return_on_err) -> T | R` **2.** `(coro, exc, return_on_err) -> T | R`
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]) - `coro` (Coroutine[Any, Any, T])
- `exc` (tuple[type[Exception], ...]) - `exc` (tuple[type[Exception], ...])
@ -184,11 +158,9 @@ description: nonebot.utils 模块
- `return_on_err` (R) - `return_on_err` (R)
- **返回** - **返回**
- T | R - T | R
- **参数** - **参数**
- `coro`: 要运行的协程 - `coro`: 要运行的协程
- `exc`: 要捕获的异常 - `exc`: 要捕获的异常
@ -204,21 +176,17 @@ description: nonebot.utils 模块
- **说明:** 运行协程并在取消时屏蔽取消异常。 - **说明:** 运行协程并在取消时屏蔽取消异常。
- **参数** - **参数**
- `coro` (Coroutine[Any, Any, T]): 要运行的协程 - `coro` (Coroutine[Any, Any, T]): 要运行的协程
- **返回** - **返回**
- T: 协程的返回值 - T: 协程的返回值
## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group} ## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group}
- **参数** - **参数**
- `exc_group` (BaseExceptionGroup[E]) - `exc_group` (BaseExceptionGroup[E])
- **返回** - **返回**
- Generator[E, None, None] - Generator[E, None, None]
## _def_ `get_name(obj)` {#get-name} ## _def_ `get_name(obj)` {#get-name}
@ -226,11 +194,9 @@ description: nonebot.utils 模块
- **说明:** 获取对象的名称 - **说明:** 获取对象的名称
- **参数** - **参数**
- `obj` (Any) - `obj` (Any)
- **返回** - **返回**
- str - str
## _def_ `path_to_module_name(path)` {#path-to-module-name} ## _def_ `path_to_module_name(path)` {#path-to-module-name}
@ -238,11 +204,9 @@ description: nonebot.utils 模块
- **说明:** 转换路径为模块名 - **说明:** 转换路径为模块名
- **参数** - **参数**
- `path` (Path) - `path` (Path)
- **返回** - **返回**
- str - str
## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation} ## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation}
@ -250,7 +214,6 @@ description: nonebot.utils 模块
- **说明:** 解析并导入点分表示法的对象 - **说明:** 解析并导入点分表示法的对象
- **参数** - **参数**
- `obj_str` (str) - `obj_str` (str)
- `default_attr` (str) - `default_attr` (str)
@ -258,7 +221,6 @@ description: nonebot.utils 模块
- `default_prefix` (str | None) - `default_prefix` (str | None)
- **返回** - **返回**
- Any - Any
## _class_ `classproperty(func)` {#classproperty} ## _class_ `classproperty(func)` {#classproperty}
@ -266,7 +228,6 @@ description: nonebot.utils 模块
- **说明:** 类属性装饰器 - **说明:** 类属性装饰器
- **参数** - **参数**
- `func` ((Any) -> T) - `func` ((Any) -> T)
## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder} ## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder}
@ -280,11 +241,9 @@ description: nonebot.utils 模块
### _method_ `default(o)` {#DataclassEncoder-default} ### _method_ `default(o)` {#DataclassEncoder-default}
- **参数** - **参数**
- `o` - `o`
- **返回** - **返回**
- untyped - untyped
## _def_ `logger_wrapper(logger_name)` {#logger-wrapper} ## _def_ `logger_wrapper(logger_name)` {#logger-wrapper}
@ -292,15 +251,12 @@ description: nonebot.utils 模块
- **说明:** 用于打印 adapter 的日志。 - **说明:** 用于打印 adapter 的日志。
- **参数** - **参数**
- `logger_name` (str): adapter 的名称 - `logger_name` (str): adapter 的名称
- **返回** - **返回**
- untyped: 日志记录函数 - untyped: 日志记录函数
日志记录函数的参数: 日志记录函数的参数:
- level: 日志等级 - level: 日志等级
- message: 日志信息 - message: 日志信息
- exception: 异常信息 - exception: 异常信息

View File

@ -289,7 +289,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
`Arparma` 有如下属性: `Arparma` 有如下属性:
- 调试类 - 调试类
- matched: 是否匹配成功 - matched: 是否匹配成功
- error_data: 解析失败时剩余的数据 - error_data: 解析失败时剩余的数据
- error_info: 解析失败时的异常内容 - error_info: 解析失败时的异常内容

View File

@ -155,7 +155,6 @@ async def test_example(app: App):
1. `should_call_send` 1. `should_call_send`
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数: 定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
- `event`:回复的目标事件。 - `event`:回复的目标事件。
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。 - `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
- `result`send 的返回值,将会返回给插件。 - `result`send 的返回值,将会返回给插件。
@ -164,7 +163,6 @@ async def test_example(app: App):
2. `should_call_api` 2. `should_call_api`
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数: 定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
- `api`API 名称。 - `api`API 名称。
- `data`:预期的请求数据。 - `data`:预期的请求数据。
- `result`call_api 的返回值,将会返回给插件。 - `result`call_api 的返回值,将会返回给插件。