From dc5c35a9edbe9c52ff7f6ef7683294dc41c49549 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Wed, 28 Oct 2020 13:17:41 +0800 Subject: [PATCH] :bulb: update command docstrinrg --- docs/api/README.md | 26 +++++++++++++------------- docs/api/rule.md | 2 ++ docs_build/README.rst | 26 +++++++++++++------------- nonebot/rule.py | 2 ++ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/docs/api/README.md b/docs/api/README.md index 710d44bd..dcfb548c 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -4,46 +4,46 @@ * **模块索引** - * [nonebot](nonebot.md) + * [nonebot](nonebot.html) - * [nonebot.config](config.md) + * [nonebot.config](config.html) - * [nonebot.plugin](plugin.md) + * [nonebot.plugin](plugin.html) - * [nonebot.matcher](matcher.md) + * [nonebot.matcher](matcher.html) - * [nonebot.rule](rule.md) + * [nonebot.rule](rule.html) - * [nonebot.permission](permission.md) + * [nonebot.permission](permission.html) - * [nonebot.sched](sched.md) + * [nonebot.sched](sched.html) - * [nonebot.log](log.md) + * [nonebot.log](log.html) - * [nonebot.utils](utils.md) + * [nonebot.utils](utils.html) - * [nonebot.typing](typing.md) + * [nonebot.typing](typing.html) - * [nonebot.exception](exception.md) + * [nonebot.exception](exception.html) * [nonebot.drivers](drivers/) - * [nonebot.drivers.fastapi](drivers/fastapi.md) + * [nonebot.drivers.fastapi](drivers/fastapi.html) * [nonebot.adapters](adapters/) - * [nonebot.adapters.cqhttp](adapters/cqhttp.md) + * [nonebot.adapters.cqhttp](adapters/cqhttp.html) diff --git a/docs/api/rule.md b/docs/api/rule.md index 32d1ae2a..9142ce2e 100644 --- a/docs/api/rule.md +++ b/docs/api/rule.md @@ -146,6 +146,8 @@ Rule(async_function, run_sync(sync_function)) 命令形式匹配,根据配置里提供的 `command_start`, `command_sep` 判断消息是否为命令。 + 可以通过 `state["_prefix"]["command"]` 获取匹配成功的命令(例:`("test",)`),通过 `state["_prefix"]["raw_command"]` 获取匹配成功的原始命令文本(例:`"/test"`)。 + * **参数** diff --git a/docs_build/README.rst b/docs_build/README.rst index 716c153c..02d097be 100644 --- a/docs_build/README.rst +++ b/docs_build/README.rst @@ -2,18 +2,18 @@ NoneBot Api Reference ===================== :模块索引: - - `nonebot `_ - - `nonebot.config `_ - - `nonebot.plugin `_ - - `nonebot.matcher `_ - - `nonebot.rule `_ - - `nonebot.permission `_ - - `nonebot.sched `_ - - `nonebot.log `_ - - `nonebot.utils `_ - - `nonebot.typing `_ - - `nonebot.exception `_ + - `nonebot `_ + - `nonebot.config `_ + - `nonebot.plugin `_ + - `nonebot.matcher `_ + - `nonebot.rule `_ + - `nonebot.permission `_ + - `nonebot.sched `_ + - `nonebot.log `_ + - `nonebot.utils `_ + - `nonebot.typing `_ + - `nonebot.exception `_ - `nonebot.drivers `_ - - `nonebot.drivers.fastapi `_ + - `nonebot.drivers.fastapi `_ - `nonebot.adapters `_ - - `nonebot.adapters.cqhttp `_ + - `nonebot.adapters.cqhttp `_ diff --git a/nonebot/rule.py b/nonebot/rule.py index f0da99a9..2802fdd8 100644 --- a/nonebot/rule.py +++ b/nonebot/rule.py @@ -200,6 +200,8 @@ def command(*cmds: Union[str, Tuple[str, ...]]) -> Rule: """ :说明: 命令形式匹配,根据配置里提供的 ``command_start``, ``command_sep`` 判断消息是否为命令。 + + 可以通过 ``state["_prefix"]["command"]`` 获取匹配成功的命令(例:``("test",)``),通过 ``state["_prefix"]["raw_command"]`` 获取匹配成功的原始命令文本(例:``"/test"``)。 :参数: * ``*cmds: Union[str, Tuple[str, ...]]``: 命令内容 :示例: