📝 Docs: 补充 Message.only 文档 (#2155)

This commit is contained in:
eya46 2023-07-07 11:28:08 +08:00 committed by GitHub
parent b2b20ffc4a
commit 770141cf0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -148,6 +148,15 @@ MessageSegment.text("text") in message
"text" in message
```
我们还可以使用消息序列的 `only` 方法来检查消息中是否仅包含指定的消息段。
```python
# 是否都为指定消息段
message.only(MessageSegment.text("test"))
# 是否仅包含指定类型的消息段
message.only("text")
```
### 过滤、索引与切片
消息序列对列表的索引与切片进行了增强,在原有列表 `int` 索引与 `slice` 切片的基础上,支持 `type` 过滤索引与切片。

View File

@ -148,6 +148,15 @@ MessageSegment.text("text") in message
"text" in message
```
我们还可以使用消息序列的 `only` 方法来检查消息中是否仅包含指定的消息段。
```python
# 是否都为指定消息段
message.only(MessageSegment.text("test"))
# 是否仅包含指定类型的消息段
message.only("text")
```
### 过滤、索引与切片
消息序列对列表的索引与切片进行了增强,在原有列表 `int` 索引与 `slice` 切片的基础上,支持 `type` 过滤索引与切片。