mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-09-21 05:12:34 +00:00
Update docs
This commit is contained in:
parent
fb5716c6e4
commit
7086739675
83
docs/api.md
83
docs/api.md
@ -1168,7 +1168,7 @@ sidebar: auto
|
|||||||
|
|
||||||
命令会话是否第一次运行。
|
命令会话是否第一次运行。
|
||||||
|
|
||||||
#### `get(key, *, prompt=None, prompt_expr=None)`
|
#### `get(key, *, prompt=None)`
|
||||||
|
|
||||||
- **说明:**
|
- **说明:**
|
||||||
|
|
||||||
@ -1180,7 +1180,6 @@ sidebar: auto
|
|||||||
|
|
||||||
- `key: Any`: 参数的键
|
- `key: Any`: 参数的键
|
||||||
- `prompt: Optional[Message_T]`: 提示的消息内容
|
- `prompt: Optional[Message_T]`: 提示的消息内容
|
||||||
- `prompt_expr: Optional[Expression_T]`: 提示的 Expression 内容,这个和 `prompt` 两者选其一,如果都不传,则不发送提示消息
|
|
||||||
|
|
||||||
- **返回:**
|
- **返回:**
|
||||||
|
|
||||||
@ -1623,63 +1622,6 @@ sidebar: auto
|
|||||||
|
|
||||||
在当前 Session 对应的上下文中发送 `hello`。
|
在当前 Session 对应的上下文中发送 `hello`。
|
||||||
|
|
||||||
#### _coroutine_ `send_expr(expr, **kwargs)`
|
|
||||||
|
|
||||||
- **说明:**
|
|
||||||
|
|
||||||
渲染 Expression,并发送生成的消息到 Session 对应的上下文中。
|
|
||||||
|
|
||||||
- **参数:**
|
|
||||||
|
|
||||||
- `expr: Expression_T`: 要发送的 Expression
|
|
||||||
- `**kwargs: Any`: 传入 `none.expression.render()` 的命名参数
|
|
||||||
|
|
||||||
- **返回:**
|
|
||||||
|
|
||||||
- `None`
|
|
||||||
|
|
||||||
- **异常:**
|
|
||||||
|
|
||||||
- `CQHttpError`: 发送失败时抛出,实际由 [aiocqhttp] 抛出,等价于 `aiocqhttp.Error`
|
|
||||||
|
|
||||||
- **用法:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
await session.send_expr(
|
|
||||||
expr=['你好,{username}!',
|
|
||||||
'欢迎回来,{username}~'],
|
|
||||||
username=username
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
## `none.expression` 模块
|
|
||||||
|
|
||||||
### `render(expr, *, escape_args=True, **kwargs)`
|
|
||||||
|
|
||||||
- **说明:**
|
|
||||||
|
|
||||||
渲染 Expression。
|
|
||||||
|
|
||||||
- **参数:**
|
|
||||||
|
|
||||||
- `expr: Expression_T`: 要渲染的 Expression
|
|
||||||
- `escape_args: bool`: 是否对渲染参数进行转义
|
|
||||||
- `**kwargs: Any`: 渲染参数,用于 `str.format()` 或 Expression 函数调用传参
|
|
||||||
|
|
||||||
- **返回:**
|
|
||||||
|
|
||||||
- `str`: 渲染出的消息字符串
|
|
||||||
|
|
||||||
- **用法:**
|
|
||||||
|
|
||||||
```python
|
|
||||||
msg = render(
|
|
||||||
expr=['你好,{username}!',
|
|
||||||
'欢迎回来,{username}~'],
|
|
||||||
username=username
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
## `none.permission` 模块
|
## `none.permission` 模块
|
||||||
|
|
||||||
### 权限声明常量
|
### 权限声明常量
|
||||||
@ -1803,34 +1745,27 @@ async def _(session):
|
|||||||
await send(bot, ctx, 'hello')
|
await send(bot, ctx, 'hello')
|
||||||
```
|
```
|
||||||
|
|
||||||
### _coroutine_ `send_expr(bot, ctx, expr, **kwargs)`
|
### `render_expression(expr, *, escape_args=True, **kwargs)`
|
||||||
|
|
||||||
- **说明:**
|
- **说明:**
|
||||||
|
|
||||||
渲染 Expression,并发送生成的消息到指定事件上下文中。
|
渲染 Expression。
|
||||||
|
|
||||||
- **参数:**
|
- **参数:**
|
||||||
|
|
||||||
- `bot: NoneBot`: NoneBot 对象
|
- `expr: Expression_T`: 要渲染的 Expression
|
||||||
- `ctx: Context_T`: 事件上下文对象
|
- `escape_args: bool`: 是否对渲染参数进行转义
|
||||||
- `expr: Expression_T`: 要发送的 Expression
|
- `**kwargs: Any`: 渲染参数,用于 `str.format()` 或 Expression 函数调用传参
|
||||||
- `**kwargs: Any`: 传入 `none.expression.render()` 的命名参数
|
|
||||||
|
|
||||||
- **返回:**
|
- **返回:**
|
||||||
|
|
||||||
- `None`
|
- `str`: 渲染出的消息字符串
|
||||||
|
|
||||||
- **异常:**
|
|
||||||
|
|
||||||
- `CQHttpError`: 发送失败时抛出,实际由 [aiocqhttp] 抛出,等价于 `aiocqhttp.Error`
|
|
||||||
|
|
||||||
- **用法:**
|
- **用法:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
await send_expr(
|
msg = render_expression(
|
||||||
bot, ctx,
|
['你好,{username}!', '欢迎,{username}~'],
|
||||||
expr=['你好,{username}!',
|
|
||||||
'欢迎回来,{username}~'],
|
|
||||||
username=username
|
username=username
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
@ -7,6 +7,7 @@ sidebar: auto
|
|||||||
## next
|
## next
|
||||||
|
|
||||||
- 修复调用不存在的多级命令(例如 `/echo/nonexist`)时,抛出异常导致 WebSocket 连接断开的问题
|
- 修复调用不存在的多级命令(例如 `/echo/nonexist`)时,抛出异常导致 WebSocket 连接断开的问题
|
||||||
|
- 调整 Expression 相关接口:移除了所有 `send_expr()` 函数和方法,移除了 `CommandSession.get()` 方法的 `prompt_expr` 参数,移除了 `none.expression` 模块,原 `render()` 函数移动到 `none.helpers` 模块并改名为 `render_expression()`
|
||||||
|
|
||||||
## v0.4.3
|
## v0.4.3
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user