mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-06-19 19:08:13 +00:00
update nonebot.message docs
This commit is contained in:
parent
51a2ca0841
commit
23ec6c7108
20
docs/api.md
20
docs/api.md
@ -1344,7 +1344,7 @@ sidebar: auto
|
|||||||
|
|
||||||
将函数装饰为消息预处理器。
|
将函数装饰为消息预处理器。
|
||||||
|
|
||||||
- **要求:**
|
- **要求:** <Badge text="1.6.0+" />
|
||||||
|
|
||||||
被装饰函数必须是一个 async 函数,且必须接收且仅接收三个位置参数,类型分别为 `NoneBot` 、 `aiocqhttp.Event` 和 `nonebot.plugin.PluginManager`,即形如:
|
被装饰函数必须是一个 async 函数,且必须接收且仅接收三个位置参数,类型分别为 `NoneBot` 、 `aiocqhttp.Event` 和 `nonebot.plugin.PluginManager`,即形如:
|
||||||
|
|
||||||
@ -1366,6 +1366,24 @@ sidebar: auto
|
|||||||
|
|
||||||
在所有消息处理之前,向消息事件对象中加入 `preprocessed` 字段。
|
在所有消息处理之前,向消息事件对象中加入 `preprocessed` 字段。
|
||||||
|
|
||||||
|
### _exception_ `CanceledException` <Badge text="1.6.0+" />
|
||||||
|
|
||||||
|
- **说明:**
|
||||||
|
|
||||||
|
取消消息处理异常
|
||||||
|
|
||||||
|
- **要求:**
|
||||||
|
|
||||||
|
在消息预处理函数 `message_preprocessor` 中可以选择抛出该异常来阻止响应该消息。
|
||||||
|
|
||||||
|
- **用法:**
|
||||||
|
|
||||||
|
```python
|
||||||
|
@message_preprocessor
|
||||||
|
async def _(bot: NoneBot, event: aiocqhttp.Event, plugin_manager: PluginManager):
|
||||||
|
raise CanceledException(reason)
|
||||||
|
```
|
||||||
|
|
||||||
### _class_ `MessageSegment`
|
### _class_ `MessageSegment`
|
||||||
|
|
||||||
从 `aiocqhttp.message` 模块导入,继承自 `dict`,用于表示一个消息段。该类型是合法的 `Message_T`。
|
从 `aiocqhttp.message` 模块导入,继承自 `dict`,用于表示一个消息段。该类型是合法的 `Message_T`。
|
||||||
|
Loading…
x
Reference in New Issue
Block a user