mirror of
https://github.com/ChenXu233/nonebot_plugin_dialectlist.git
synced 2024-11-27 17:45:07 +08:00
🎨 结构化代码
This commit is contained in:
parent
833cdb4a75
commit
5e00605dfb
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -19,6 +19,7 @@
|
|||||||
"pygal",
|
"pygal",
|
||||||
"sqlalchemy",
|
"sqlalchemy",
|
||||||
"timecost",
|
"timecost",
|
||||||
|
"uninfo",
|
||||||
"userinfo",
|
"userinfo",
|
||||||
"whereclause",
|
"whereclause",
|
||||||
"xaxis",
|
"xaxis",
|
||||||
|
@ -95,15 +95,16 @@ 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],
|
||||||
group_id: Match[str],
|
group_id: Match[str],
|
||||||
keyword: Match[str],
|
keyword: Match[str],
|
||||||
uninfo: Uninfo,
|
uninfo: Uninfo,
|
||||||
@ -116,10 +117,10 @@ async def handle_b_cmd(
|
|||||||
gid = group_id.result
|
gid = group_id.result
|
||||||
else:
|
else:
|
||||||
gid = session.id2
|
gid = session.id2
|
||||||
|
|
||||||
if not gid:
|
if not gid:
|
||||||
await b_cmd.finish("请指定群号。")
|
await b_cmd.finish("请指定群号。")
|
||||||
|
|
||||||
if keyword.available:
|
if keyword.available:
|
||||||
keywords = keyword.result
|
keywords = keyword.result
|
||||||
else:
|
else:
|
||||||
@ -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(
|
||||||
@ -357,7 +362,7 @@ async def handle_rank(
|
|||||||
msg += suffix
|
msg += suffix
|
||||||
if not msg:
|
if not msg:
|
||||||
await saa.Text("你把可视化都关了哪来的排行榜?").finish()
|
await saa.Text("你把可视化都关了哪来的排行榜?").finish()
|
||||||
|
|
||||||
if plugin_config.aggregate_transmission:
|
if plugin_config.aggregate_transmission:
|
||||||
await saa.AggregatedMessageFactory([msg]).finish()
|
await saa.AggregatedMessageFactory([msg]).finish()
|
||||||
else:
|
else:
|
||||||
|
@ -13,7 +13,7 @@ class ScopedConfig(BaseModel):
|
|||||||
counting_cache: bool = False # 计数缓存(能够提高回复速度)
|
counting_cache: bool = False # 计数缓存(能够提高回复速度)
|
||||||
excluded_people: List[str] = [] # 排除的人的QQ号
|
excluded_people: List[str] = [] # 排除的人的QQ号
|
||||||
use_user_info_cache: bool = False # 是否使用用户信息缓存
|
use_user_info_cache: bool = False # 是否使用用户信息缓存
|
||||||
aggregate_transmission:bool = False # 是否聚合转发消息
|
aggregate_transmission: bool = False # 是否聚合转发消息
|
||||||
timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
|
timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
|
||||||
string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
|
string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
|
||||||
template_path: str = "./template/rank_template.j2" # 模板路径
|
template_path: str = "./template/rank_template.j2" # 模板路径
|
||||||
|
Loading…
Reference in New Issue
Block a user