🎨 结构化代码

This commit is contained in:
XuChenXu 2024-11-25 21:18:09 +08:00
parent 833cdb4a75
commit 5e00605dfb
3 changed files with 15 additions and 9 deletions

View File

@ -19,6 +19,7 @@
"pygal", "pygal",
"sqlalchemy", "sqlalchemy",
"timecost", "timecost",
"uninfo",
"userinfo", "userinfo",
"whereclause", "whereclause",
"xaxis", "xaxis",

View File

@ -95,12 +95,13 @@ b_cmd = on_alconna(
"看看B话", "看看B话",
Args["at", [str, At], Field(completion=lambda: "请想要查询的人的QQ号")], Args["at", [str, At], Field(completion=lambda: "请想要查询的人的QQ号")],
Option("-g|--group_id", Args["group_id?", str]), Option("-g|--group_id", Args["group_id?", str]),
Option("-k|--keyword", Args["keyword?", str]) Option("-k|--keyword", Args["keyword?", str]),
), ),
aliases={"kkb"}, aliases={"kkb"},
use_cmd_start=True, use_cmd_start=True,
) )
@b_cmd.handle() @b_cmd.handle()
async def handle_b_cmd( async def handle_b_cmd(
at: Match[str | At], at: Match[str | At],
@ -137,9 +138,13 @@ async def handle_b_cmd(
d = msg_counter(messages, keywords) d = msg_counter(messages, keywords)
rank = got_rank(d) rank = got_rank(d)
if not rank: if not rank:
await b_cmd.finish(f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为0。") await b_cmd.finish(
f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为0。"
)
await saa.Text(f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为{rank[0][1]}").send(reply=True) await saa.Text(
f"该用户在群“{uninfo.scene.name}”关于“{keyword}”的B话数量为{rank[0][1]}"
).send(reply=True)
rank_cmd = on_alconna( rank_cmd = on_alconna(