🎨 update avatar list split count style

This commit is contained in:
xtaodada 2024-05-27 21:20:51 +08:00
parent 124c7533d7
commit e634711648
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 11 additions and 5 deletions

View File

@ -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)

View File

@ -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)