From 53b2a33923873e4123e0b8c624881b386c80a53d Mon Sep 17 00:00:00 2001 From: XuChenXu <91937041+ChenXu233@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:39:07 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=90=88=E5=B9=B6=E8=BD=AC?= =?UTF-8?q?=E5=8F=91=E5=BC=80=E5=85=B3=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_dialectlist/__init__.py | 17 +++++++++++++---- nonebot_plugin_dialectlist/config.py | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_dialectlist/__init__.py b/nonebot_plugin_dialectlist/__init__.py index 58e4887..dd4d974 100644 --- a/nonebot_plugin_dialectlist/__init__.py +++ b/nonebot_plugin_dialectlist/__init__.py @@ -85,6 +85,12 @@ async def _build_cache(bot: Bot, event: Event): await saa.Text("重建缓存完成。").send(reply=True) +b_cmd = on_alconna( + Alconna( + "看看他的B话", + ) +) + rank_cmd = on_alconna( Alconna( "B话榜", @@ -267,7 +273,7 @@ async def handle_rank( t1 = t.time() rank2 = await get_user_infos(bot, event, rank) logger.debug(f"获取用户信息花费时间:{t.time() - t1}") - + string: str = "" if plugin_config.show_text_rank: @@ -275,7 +281,7 @@ async def handle_rank( string += f"关于{keyword}的话痨榜结果:\n" else: string += "话痨榜:\n" - + for i in rank2: logger.debug(i.user_name) for i in range(len(rank2)): @@ -300,5 +306,8 @@ async def handle_rank( msg += suffix if not msg: await saa.Text("你把可视化都关了哪来的排行榜?").finish() - - await msg.finish(reply=True) + + if plugin_config.aggregate_transmission: + await saa.AggregatedMessageFactory([msg]).finish(reply=True) + else: + await msg.finish(reply=True) diff --git a/nonebot_plugin_dialectlist/config.py b/nonebot_plugin_dialectlist/config.py index e93d528..6f5a609 100644 --- a/nonebot_plugin_dialectlist/config.py +++ b/nonebot_plugin_dialectlist/config.py @@ -9,10 +9,11 @@ class ScopedConfig(BaseModel): suffix: bool = True # 是否显示后缀 excluded_self: bool = True # 是否排除自己 visualization: bool = True # 是否可视化 - show_text_rank:bool = True # 是否显示文本排名 + show_text_rank: bool = True # 是否显示文本排名 counting_cache: bool = False # 计数缓存(能够提高回复速度) excluded_people: List[str] = [] # 排除的人的QQ号 use_user_info_cache: bool = False # 是否使用用户信息缓存 + aggregate_transmission:bool = False # 是否聚合转发消息 timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间 string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀 template_path: str = "./template/rank_template.j2" # 模板路径