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:
Mix 2022-02-16 20:24:00 +08:00 committed by GitHub
parent fcda5c37d7
commit 43aebd9c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -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://...'}))
``` ```

View File

@ -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://...'}))
``` ```