mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-20 17:46:51 +08:00
📝 Docs: 补充 Message.only 文档 (#2155)
This commit is contained in:
parent
b2b20ffc4a
commit
770141cf0a
@ -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` 过滤索引与切片。
|
||||
|
@ -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` 过滤索引与切片。
|
||||
|
Loading…
x
Reference in New Issue
Block a user