📝 update api docs

This commit is contained in:
AkiraXie
2021-02-01 17:22:53 +00:00
parent f8fb36a1f7
commit c8ebaf38b6
2 changed files with 95 additions and 0 deletions

View File

@ -170,6 +170,44 @@ Rule(async_function, run_sync(sync_function))
:::
## `shell_like_command(shell_like_argsparser=None, *cmds)`
* **说明**
支持 `shell_like` 解析参数的命令形式匹配,根据配置里提供的 `command_start`, `command_sep` 判断消息是否为命令。
可以通过 `state["_prefix"]["command"]` 获取匹配成功的命令(例:`("test",)`),通过 `state["_prefix"]["raw_command"]` 获取匹配成功的原始命令文本(例:`"/test"`)。
添加 `shell_like_argpsarser` 参数后, 可以自动处理消息并将结果保存在 `state["args"]` 中。
* **参数**
* `shell_like_argsparser: Optional[ArgumentParser]`: `argparse.ArgumentParser` 对象, 是一个类 `shell``argsparser`
* `*cmds: Union[str, Tuple[str, ...]]`: 命令内容
* **示例**
使用默认 `command_start`, `command_sep` 配置
命令 `("test",)` 可以匹配:`/test` 开头的消息
命令 `("test", "sub")` 可以匹配”`/test.sub` 开头的消息
`shell_like_argsparser``argument``-a` 时且 `action``store_true` `state["args"]["a"]` 将会记录 `True`
:::tip 提示
命令内容与后续消息间无需空格!
:::
## `regex(regex, flags=0)`