🎨 Optimize /gacha_log long image send method

This commit is contained in:
LittleMengBot 2023-03-16 15:47:24 +08:00 committed by GitHub
parent 6d540b9c66
commit c25184f3de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -317,8 +317,15 @@ class WishLogPlugin(Plugin.Conversation):
else:
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
png_data = await self.template_service.render(
"genshin/gacha_log/gacha_log.html", data, full_page=True, query_selector=".body_box"
"genshin/gacha_log/gacha_log.html",
data,
full_page=True,
file_type=FileType.DOCUMENT if len(data.get("fiveLog")) > 36 else FileType.PHOTO,
query_selector=".body_box",
)
if png_data.file_type == FileType.DOCUMENT:
await png_data.reply_document(message, filename="抽卡记录.png")
else:
await png_data.reply_photo(message)
except GachaLogNotFound:
logger.info("未找到用户 %s[%s] 的抽卡记录", user.full_name, user.id)