From e634711648d5c4a50cf1f5cb286f458b544e67b2 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 27 May 2024 21:20:51 +0800 Subject: [PATCH] :art: update avatar list split count style --- plugins/genshin/abyss.py | 5 ++++- plugins/genshin/avatar_list.py | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/genshin/abyss.py b/plugins/genshin/abyss.py index 31096d22..a874205b 100644 --- a/plugins/genshin/abyss.py +++ b/plugins/genshin/abyss.py @@ -506,6 +506,9 @@ class AbyssPlugin(Plugin): """渲染层数数据""" callback_query = update.callback_query message = callback_query.message + reply = None + if message.reply_to_message: + reply = message.reply_to_message floor = 0 total = False @@ -534,7 +537,7 @@ class AbyssPlugin(Plugin): for group in ArkoWrapper(images).group(10): # 每 10 张图片分一个组 await RenderGroupResult(results=group).reply_media_group( - message, allow_sending_without_reply=True, write_timeout=60 + reply or message, allow_sending_without_reply=True, write_timeout=60 ) self.log_user(update, logger.info, "[bold]深渊挑战数据[/bold]: 成功发送图片", extra={"markup": True}) self.add_delete_message_job(message, delay=1) diff --git a/plugins/genshin/avatar_list.py b/plugins/genshin/avatar_list.py index 51130e11..2d62c7ac 100644 --- a/plugins/genshin/avatar_list.py +++ b/plugins/genshin/avatar_list.py @@ -1,4 +1,5 @@ import asyncio +import math from typing import List, Optional, Sequence, TYPE_CHECKING, Union, Tuple, Any, Dict from arkowrapper import ArkoWrapper @@ -160,10 +161,12 @@ class AvatarListPlugin(Plugin): if only_one_page: return [await render_task(0, avatar_datas)] - avatar_datas_group = [ - avatar_datas[i : i + MAX_AVATAR_COUNT] for i in range(0, len(avatar_datas), MAX_AVATAR_COUNT) - ] - tasks = [render_task(i * MAX_AVATAR_COUNT, c) for i, c in enumerate(avatar_datas_group)] + image_count = len(avatar_datas) + while image_count > MAX_AVATAR_COUNT: + image_count /= 2 + image_count = math.ceil(image_count) + avatar_datas_group = [avatar_datas[i : i + image_count] for i in range(0, len(avatar_datas), image_count)] + tasks = [render_task(i * image_count, c) for i, c in enumerate(avatar_datas_group)] return await asyncio.gather(*tasks) @handler.command("avatars", cookie=True, block=False)