From d2e185c18952e3e77970bca3faa5fb717a83faca Mon Sep 17 00:00:00 2001 From: XuChenXu <91937041+ChenXu233@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:28:32 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=98=BE=E7=A4=BA=E6=96=87=E6=9C=AC=E6=8E=92=E8=A1=8C?= =?UTF-8?q?=E6=A6=9C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_dialectlist/__init__.py | 29 ++++++++++++++------------ nonebot_plugin_dialectlist/config.py | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/nonebot_plugin_dialectlist/__init__.py b/nonebot_plugin_dialectlist/__init__.py index fc55153..8af4786 100644 --- a/nonebot_plugin_dialectlist/__init__.py +++ b/nonebot_plugin_dialectlist/__init__.py @@ -257,30 +257,33 @@ async def handle_rank( t1 = t.time() rank2 = await get_user_infos(bot, event, rank) logger.debug(f"获取用户信息花费时间:{t.time() - t1}") - + string: str = "" - for i in rank2: - logger.debug(i.user_name) - for i in range(len(rank2)): - str_example = plugin_config.string_format.format( - index=rank2[i].user_index, - nickname=rank2[i].user_nickname, - chatdatanum=rank2[i].user_bnum, - ) - string += str_example + + if plugin_config.show_text_rank: + for i in rank2: + logger.debug(i.user_name) + for i in range(len(rank2)): + str_example = plugin_config.string_format.format( + index=rank2[i].user_index, + nickname=rank2[i].user_nickname, + chatdatanum=rank2[i].user_bnum, + ) + string += str_example msg = saa.Text(string) - t1 = t.time() if plugin_config.visualization: + t1 = t.time() image = await get_rank_image(rank2) msg += saa.Image(image) + logger.debug(f"群聊消息渲染图片花费时间:{t.time() - t1}") if plugin_config.suffix: timecost = t.time() - state["t1"] suffix = saa.Text(plugin_config.string_suffix.format(timecost=timecost)) msg += suffix - - logger.debug(f"群聊消息渲染图片花费时间:{t.time() - t1}") + if not msg: + await saa.Text("你把可视化都关了哪来的排行榜?").finish() await msg.finish(reply=True) diff --git a/nonebot_plugin_dialectlist/config.py b/nonebot_plugin_dialectlist/config.py index d2f68b3..e93d528 100644 --- a/nonebot_plugin_dialectlist/config.py +++ b/nonebot_plugin_dialectlist/config.py @@ -9,6 +9,7 @@ class ScopedConfig(BaseModel): suffix: bool = True # 是否显示后缀 excluded_self: bool = True # 是否排除自己 visualization: bool = True # 是否可视化 + show_text_rank:bool = True # 是否显示文本排名 counting_cache: bool = False # 计数缓存(能够提高回复速度) excluded_people: List[str] = [] # 排除的人的QQ号 use_user_info_cache: bool = False # 是否使用用户信息缓存