mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 15:36:44 +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():
|
if not file_path.exists():
|
||||||
return None
|
return None
|
||||||
try:
|
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:
|
except jsonlib.JSONDecodeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -65,10 +68,9 @@ class PlayerCardsFile:
|
|||||||
if old_data is None:
|
if old_data is None:
|
||||||
await self.save_json(self.get_file_path(uid), data)
|
await self.save_json(self.get_file_path(uid), data)
|
||||||
return data
|
return data
|
||||||
if data.get("avatarInfoList") is None:
|
data["avatarInfoList"] = data.get("avatars") or []
|
||||||
data["avatarInfoList"] = []
|
|
||||||
characters = [i.get("avatarId", 0) for i in data["avatarInfoList"]]
|
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:
|
if i.get("avatarId", 0) not in characters:
|
||||||
data["avatarInfoList"].append(i)
|
data["avatarInfoList"].append(i)
|
||||||
await self.save_json(self.get_file_path(uid), data)
|
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)
|
original_data = await self.player_cards_file.load_history_info(uid)
|
||||||
if original_data is None:
|
if original_data is None:
|
||||||
return []
|
return []
|
||||||
if original_data.get("avatarInfoList") is None:
|
|
||||||
original_data["avatarInfoList"] = []
|
|
||||||
if len(original_data["avatarInfoList"]) == 0:
|
if len(original_data["avatarInfoList"]) == 0:
|
||||||
return []
|
return []
|
||||||
enka_response: EnkaNetworkResponse = EnkaNetworkResponse.parse_obj(
|
enka_response: EnkaNetworkResponse = EnkaNetworkResponse.parse_obj(
|
||||||
|
@ -188,8 +188,6 @@ class PlayerCards(Plugin):
|
|||||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||||
return
|
return
|
||||||
original_data = await self._load_history(uid)
|
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 original_data is None or len(original_data["avatarInfoList"]) == 0:
|
||||||
if isinstance(self.kitsune, str):
|
if isinstance(self.kitsune, str):
|
||||||
photo = self.kitsune
|
photo = self.kitsune
|
||||||
|
Loading…
Reference in New Issue
Block a user