mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-12 06:56:41 +00:00
📝 Update changelog
Some checks failed
Ruff Lint / Ruff Lint (push) Successful in 18s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 1m39s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 1m48s
Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 1m20s
Site Deploy / publish (push) Failing after 11m5s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.9) (push) Failing after 12m1s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 12m2s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 12m5s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.9) (push) Failing after 12m6s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 12m10s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 17m50s
Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 18m23s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (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.9) (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
Some checks failed
Ruff Lint / Ruff Lint (push) Successful in 18s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 1m39s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 1m48s
Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 1m20s
Site Deploy / publish (push) Failing after 11m5s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.9) (push) Failing after 12m1s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 12m2s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 12m5s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.9) (push) Failing after 12m6s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 12m10s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 17m50s
Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 18m23s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (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.9) (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:
@ -101,6 +101,7 @@ async def send(
|
||||
) -> Receipt:
|
||||
...
|
||||
```
|
||||
|
||||
- `target`: 发送目标,支持事件和[发送对象](./utils.mdx#发送对象),不传入时会尝试从响应器上下文中获取。
|
||||
- `bot`: 发送消息使用的 Bot 对象,若不传入则会尝试从响应器上下文中获取。
|
||||
- `fallback`: [回退策略](#回退策略)。
|
||||
@ -134,6 +135,7 @@ async def tt(target: At):
|
||||
### 回退策略
|
||||
|
||||
`send` 方法的 `fallback` 参数用于指定回退策略(即当前适配器不支持的消息段如何处理):
|
||||
|
||||
- `FallbackStrategy.ignore`: 忽略未转换的消息段
|
||||
- `FallbackStrategy.to_text`: 将未转换的消息段转为文本元素
|
||||
- `FallbackStrategy.rollback`: 从未转换消息段的子元素中提取可能的可发送消息段
|
||||
@ -178,6 +180,7 @@ async def handle():
|
||||
```
|
||||
|
||||
`Receipt` 对象拥有以下方法:
|
||||
|
||||
- `recallable`: 表明是否可以撤回
|
||||
- `recall`: 撤回消息
|
||||
- `editable`: 表明是否可以修改
|
||||
@ -188,7 +191,6 @@ async def handle():
|
||||
- `send`, `finish`: 发送消息
|
||||
- `reply`: 回复已经发送的消息
|
||||
|
||||
|
||||
## 构造
|
||||
|
||||
如同 `Message`, `UniMessage` 可以传入单个字符串/消息段,或可迭代的字符串/消息段:
|
||||
@ -268,7 +270,6 @@ async def tt():
|
||||
|
||||
:::
|
||||
|
||||
|
||||
### 拼接消息
|
||||
|
||||
`str`、`UniMessage`、`Segment` 对象之间可以直接相加,相加均会返回一个新的 `UniMessage` 对象:
|
||||
@ -447,15 +448,15 @@ message.transform(rule)
|
||||
转换规则的类型一般为 `dict[str, Transformer]`,以消息元素类型的名称为键,定义方式如下:
|
||||
|
||||
```typescript
|
||||
type Fragment = Segment | Segment[]
|
||||
type Render<T> = (attrs: dict, children: Segment[]) => T
|
||||
type Transformer = boolean | Fragment | Render<boolean | Fragment>
|
||||
type Fragment = Segment | Segment[];
|
||||
type Render<T> = (attrs: dict, children: Segment[]) => T;
|
||||
type Transformer = boolean | Fragment | Render<boolean | Fragment>;
|
||||
```
|
||||
|
||||
|
||||
### 字符串操作
|
||||
|
||||
类似于 `str`,消息序列可以通过如下方法来操作消息内的文本部分:
|
||||
|
||||
- `split`,
|
||||
- `replace`,
|
||||
- `startwith`, `endswith`,
|
||||
@ -499,6 +500,7 @@ def dump(self, media_save_dir: str | Path | bool | None = None, json: bool = Fal
|
||||
```
|
||||
|
||||
其中,`media_save_dir` 用于指定持久化的媒体文件存储目录:
|
||||
|
||||
- 若 `media_save_dir` 为 str 或 Path,则会将媒体文件保存到指定目录下。
|
||||
- 若 `media_save_dir` 为 False,则不会保存媒体文件。
|
||||
- 若 `media_save_dir` 为 True,则会将文件数据转为 base64 编码。
|
||||
|
@ -35,7 +35,7 @@ class Text(Segment):
|
||||
"""Text对象, 表示一类文本元素"""
|
||||
text: str
|
||||
styles: dict[tuple[int, int], list[str]]
|
||||
|
||||
|
||||
def cover(self, text: str): ...
|
||||
def mark(self, start: Optional[int] = None, end: Optional[int] = None, *styles: str): ...
|
||||
|
||||
|
@ -16,7 +16,6 @@ import TabItem from "@theme/TabItem";
|
||||
|
||||
:::
|
||||
|
||||
|
||||
## 消息事件 ID
|
||||
|
||||
消息事件 ID 是用来标识当前消息事件的唯一 ID,通常用于回复/撤回/编辑/表态当前消息。
|
||||
@ -175,7 +174,6 @@ async def _():
|
||||
若配置了 [`alconna_apply_fetch_targets`](../config.md#alconna_apply_fetch_targets) 选项,则在启动时会主动拉取一次发送对象列表。即对于
|
||||
某一主动构造的 `Target` 对象,插件将其与拉取下来的众多发送对象进行匹配,并选择第一个符合条件的发送对象,以选择对应的 Bot 对象。
|
||||
|
||||
|
||||
## 撤回消息
|
||||
|
||||
通过 `message_recall` 方法来撤回消息事件。
|
||||
@ -271,6 +269,7 @@ async def message_reaction(
|
||||
## 响应规则
|
||||
|
||||
`uniseg` 模块提供了两个响应规则:
|
||||
|
||||
- `at_in`: 是否在消息中 @ 了指定的用户
|
||||
- `at_me`: 是否在消息中 @ 了机器人
|
||||
|
||||
|
Reference in New Issue
Block a user