📝 Docs: 更新最佳实践的 Alconna 部分 (#2656)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Tarrailt
2024-04-18 18:28:31 +08:00
committed by GitHub
parent cbecc7b930
commit b0d554eacb
5 changed files with 468 additions and 193 deletions

View File

@ -102,17 +102,16 @@ async def got_location(location: str = ArgPlainText()):
</details>
```python {5-10,14-16,18-19}
```python {5-9,13-15,17-18}
from nonebot.rule import to_me
from arclet.alconna import Alconna, Args
from nonebot_plugin_alconna import Match, on_alconna
weather = on_alconna(
Alconna("天气", Args["location?", str]),
aliases={"weather", "天气预报"},
rule=to_me(),
)
weather.shortcut("weather", {"command": "天气"})
weather.shortcut("天气预报", {"command": "天气"})
@weather.handle()
@ -133,7 +132,7 @@ async def got_location(location: str):
或阅读 [Alconna 基本介绍](./command.md) 一节。
关于更多 `on_alconna` 的使用方法,可参考 [插件文档](https://github.com/nonebot/plugin-alconna/blob/master/docs.md)
或阅读 [响应规则的使用](./matcher.md) 一节。
或阅读 [响应规则的使用](./matcher.mdx) 一节。
## 交流与反馈