mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 06:55:36 +08:00
Docs: 修改消息模板文档中错误的样例 (#806)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
This commit is contained in:
parent
fcda5c37d7
commit
43aebd9c93
@ -227,7 +227,7 @@ Message(
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python title="对消息段进行安全的拼接"
|
```python title="对消息段进行安全的拼接"
|
||||||
>>> Message.template("{} {}").format(MessageSegment.image("file:///..."), "world")
|
>>> Message.template("{}{}").format(MessageSegment.image("file:///..."), "world")
|
||||||
Message(
|
Message(
|
||||||
MessageSegment(type='image', data={'file': 'file:///...'}),
|
MessageSegment(type='image', data={'file': 'file:///...'}),
|
||||||
MessageSegment(type='text', data={'text': 'world'})
|
MessageSegment(type='text', data={'text': 'world'})
|
||||||
@ -236,17 +236,18 @@ Message(
|
|||||||
|
|
||||||
```python title="以消息对象作为模板"
|
```python title="以消息对象作为模板"
|
||||||
>>> Message.template(
|
>>> Message.template(
|
||||||
... MessageSegment.text('test {user_id}') + MessageSegment.face(233) +
|
... MessageSegment.text('{user_id}') + MessageSegment.face(233) +
|
||||||
... MessageSegment.text('test {message}')).format_map({'user_id':123456, 'message':'hello world'}
|
... MessageSegment.text('{message}')
|
||||||
... )
|
... ).format_map({'user_id':123456, 'message':'hello world'}
|
||||||
|
...
|
||||||
Message(
|
Message(
|
||||||
MessageSegment(type='text', data={'text': 'test 123456'}),
|
MessageSegment(type='text', data={'text': '123456'}),
|
||||||
MessageSegment(type='face', data={'face': 233}),
|
MessageSegment(type='face', data={'face': 233}),
|
||||||
MessageSegment(type='text', data={'text': 'test hello world'})
|
MessageSegment(type='text', data={'text': 'hello world'})
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```python title="使用消息段的拓展格式规格"
|
```python title="使用消息段的拓展控制符"
|
||||||
>>> Message.template("{link:image}").format(link='https://...')
|
>>> Message.template("{link:image}").format(link='https://...')
|
||||||
Message(MessageSegment(type='image', data={'file': 'https://...'}))
|
Message(MessageSegment(type='image', data={'file': 'https://...'}))
|
||||||
```
|
```
|
||||||
|
@ -227,7 +227,7 @@ Message(
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python title="对消息段进行安全的拼接"
|
```python title="对消息段进行安全的拼接"
|
||||||
>>> Message.template("{} {}").format(MessageSegment.image("file:///..."), "world")
|
>>> Message.template("{}{}").format(MessageSegment.image("file:///..."), "world")
|
||||||
Message(
|
Message(
|
||||||
MessageSegment(type='image', data={'file': 'file:///...'}),
|
MessageSegment(type='image', data={'file': 'file:///...'}),
|
||||||
MessageSegment(type='text', data={'text': 'world'})
|
MessageSegment(type='text', data={'text': 'world'})
|
||||||
@ -236,17 +236,18 @@ Message(
|
|||||||
|
|
||||||
```python title="以消息对象作为模板"
|
```python title="以消息对象作为模板"
|
||||||
>>> Message.template(
|
>>> Message.template(
|
||||||
... MessageSegment.text('test {user_id}') + MessageSegment.face(233) +
|
... MessageSegment.text('{user_id}') + MessageSegment.face(233) +
|
||||||
... MessageSegment.text('test {message}')).format_map({'user_id':123456, 'message':'hello world'}
|
... MessageSegment.text('{message}')
|
||||||
... )
|
... ).format_map({'user_id':123456, 'message':'hello world'}
|
||||||
|
...
|
||||||
Message(
|
Message(
|
||||||
MessageSegment(type='text', data={'text': 'test 123456'}),
|
MessageSegment(type='text', data={'text': '123456'}),
|
||||||
MessageSegment(type='face', data={'face': 233}),
|
MessageSegment(type='face', data={'face': 233}),
|
||||||
MessageSegment(type='text', data={'text': 'test hello world'})
|
MessageSegment(type='text', data={'text': 'hello world'})
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```python title="使用消息段的拓展格式规格"
|
```python title="使用消息段的拓展控制符"
|
||||||
>>> Message.template("{link:image}").format(link='https://...')
|
>>> Message.template("{link:image}").format(link='https://...')
|
||||||
Message(MessageSegment(type='image', data={'file': 'https://...'}))
|
Message(MessageSegment(type='image', data={'file': 'https://...'}))
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user