mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 07:07:46 +00:00
🐛 Fix load old player card info TypeError
This commit is contained in:
parent
bc0f6c86d5
commit
d64b763a29
@ -51,7 +51,10 @@ class PlayerCardsFile:
|
||||
if not file_path.exists():
|
||||
return None
|
||||
try:
|
||||
return await self.load_json(file_path)
|
||||
data = await self.load_json(file_path)
|
||||
if data:
|
||||
data["avatarInfoList"] = data.get("avatarInfoList") or []
|
||||
return data
|
||||
except jsonlib.JSONDecodeError:
|
||||
return None
|
||||
|
||||
@ -65,10 +68,9 @@ class PlayerCardsFile:
|
||||
if old_data is None:
|
||||
await self.save_json(self.get_file_path(uid), data)
|
||||
return data
|
||||
if data.get("avatarInfoList") is None:
|
||||
data["avatarInfoList"] = []
|
||||
data["avatarInfoList"] = data.get("avatars") or []
|
||||
characters = [i.get("avatarId", 0) for i in data["avatarInfoList"]]
|
||||
for i in old_data.get("avatarInfoList", []):
|
||||
for i in old_data["avatarInfoList"]:
|
||||
if i.get("avatarId", 0) not in characters:
|
||||
data["avatarInfoList"].append(i)
|
||||
await self.save_json(self.get_file_path(uid), data)
|
||||
|
@ -152,8 +152,6 @@ class GCSimPlugin(Plugin):
|
||||
original_data = await self.player_cards_file.load_history_info(uid)
|
||||
if original_data is None:
|
||||
return []
|
||||
if original_data.get("avatarInfoList") is None:
|
||||
original_data["avatarInfoList"] = []
|
||||
if len(original_data["avatarInfoList"]) == 0:
|
||||
return []
|
||||
enka_response: EnkaNetworkResponse = EnkaNetworkResponse.parse_obj(
|
||||
|
@ -188,8 +188,6 @@ class PlayerCards(Plugin):
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
original_data = await self._load_history(uid)
|
||||
if original_data and not original_data.get("avatarInfoList"):
|
||||
original_data["avatarInfoList"] = []
|
||||
if original_data is None or len(original_data["avatarInfoList"]) == 0:
|
||||
if isinstance(self.kitsune, str):
|
||||
photo = self.kitsune
|
||||
|
Loading…
Reference in New Issue
Block a user