From ec058517467639ad12a5799446e9cb9ec0a41cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Mon, 10 Jul 2023 00:42:36 +0800 Subject: [PATCH] :bug: Fix check for `EnkaNetworkResponse.characters` --- plugins/genshin/player_cards.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/genshin/player_cards.py b/plugins/genshin/player_cards.py index b98fe2e..99ca235 100644 --- a/plugins/genshin/player_cards.py +++ b/plugins/genshin/player_cards.py @@ -162,8 +162,17 @@ class PlayerCards(Plugin): else: logger.info("用户 %s[%s] 角色卡片查询命令请求", user.full_name, user.id) ttl = await self.cache.ttl(player_info.player_id) - - buttons = self.gen_button(data, user.id, player_info.player_id, update_button=ttl < 0) + if data.characters is None or len(data.characters) == 0: + buttons = [ + [ + InlineKeyboardButton( + "更新面板", + callback_data=f"update_player_card|{user.id}|{player_info.player_id,}", + ) + ] + ] + else: + buttons = self.gen_button(data, user.id, player_info.player_id, update_button=ttl < 0) if isinstance(self.kitsune, str): photo = self.kitsune else: @@ -221,7 +230,7 @@ class PlayerCards(Plugin): if isinstance(data, str): await callback_query.answer(text=data, show_alert=True) return - if len(data.characters) == 0: + if data.characters is None or len(data.characters) == 0: await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True) await message.delete() return @@ -286,7 +295,7 @@ class PlayerCards(Plugin): if isinstance(data, str): await message.reply_text(data) return - if len(data.characters) == 0: + if data.characters is None or len(data.characters) == 0: await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True) await message.delete() return