From 32858a5e006e38a56d689985995a9a09a85592a3 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Thu, 1 Sep 2022 14:03:01 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=B7=B1=E6=B8=8A?= =?UTF-8?q?=E6=98=9F=E6=95=B0=E4=BC=9A=E8=AE=A1=E7=AE=97=E5=89=8D8?= =?UTF-8?q?=E5=B1=82=E5=92=8C=E5=8E=9F=E7=A5=9E=E8=AF=AD=E9=9F=B3=E5=90=88?= =?UTF-8?q?=E6=88=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/database/models/abyss_info.py | 29 ++++++++++++------- .../plugins/Genshin_AIVoice/__init__.py | 5 ++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/LittlePaimon/database/models/abyss_info.py b/LittlePaimon/database/models/abyss_info.py index 5193a9d..ff156ea 100644 --- a/LittlePaimon/database/models/abyss_info.py +++ b/LittlePaimon/database/models/abyss_info.py @@ -125,17 +125,23 @@ class AbyssInfo(Model): """总星数""" max_floor: str = fields.CharField(max_length=255, null=True) """到达层数""" - max_battle: AbyssCharacters = fields.JSONField(encoder=AbyssCharacters.json, decoder=AbyssCharacters.parse_raw, null=True) + max_battle: AbyssCharacters = fields.JSONField(encoder=AbyssCharacters.json, decoder=AbyssCharacters.parse_raw, + null=True) """出战次数最多""" - max_defeat: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, null=True) + max_defeat: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, + null=True) """击败最多""" - max_damage: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, null=True) + max_damage: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, + null=True) """伤害最高""" - max_take_damage: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, null=True) + max_take_damage: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, + null=True) """承受伤害最高""" - max_normal_skill: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, null=True) + max_normal_skill: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, + null=True) """元素战技释放最多""" - max_energy_skill: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, null=True) + max_energy_skill: AbyssCharacter = fields.JSONField(encoder=AbyssCharacter.json, decoder=AbyssCharacter.parse_raw, + null=True) """元素爆发释放最多""" floors: Floors = fields.JSONField(encoder=Floors.json, decoder=Floors.parse_raw, default=Floors()) """楼层具体信息""" @@ -161,14 +167,14 @@ class AbyssInfo(Model): if 'reveal_rank' in data and data['reveal_rank']: info.max_battle = AbyssCharacters(characters=[ AbyssCharacter(name=get_name_by_id(c['avatar_id']), - character_id=c['avatar_id'], + character_id=c['avatar_id'], icon=c['avatar_icon'].split('/')[-1].replace('.png', ''), rarity=c['rarity'], value=c['value']) for c in data['reveal_rank'] ]) if 'defeat_rank' in data and data['defeat_rank']: info.max_defeat = AbyssCharacter(name=get_name_by_id(data['defeat_rank'][0]['avatar_id']), - character_id=data['defeat_rank'][0]['avatar_id'], + character_id=data['defeat_rank'][0]['avatar_id'], icon=data['defeat_rank'][0]['avatar_icon'].split('/')[-1].replace('.png', '').replace( 'Side_', ''), @@ -183,7 +189,8 @@ class AbyssInfo(Model): rarity=data['damage_rank'][0]['rarity'], value=data['damage_rank'][0]['value']) if 'take_damage_rank' in data and data['take_damage_rank']: - info.max_take_damage = AbyssCharacter(name=get_name_by_id(data['take_damage_rank'][0]['avatar_id']), character_id=data['take_damage_rank'][0]['avatar_id'], + info.max_take_damage = AbyssCharacter(name=get_name_by_id(data['take_damage_rank'][0]['avatar_id']), + character_id=data['take_damage_rank'][0]['avatar_id'], icon=data['take_damage_rank'][0]['avatar_icon'].split('/')[ -1].replace( '.png', '').replace('Side_', ''), @@ -205,8 +212,8 @@ class AbyssInfo(Model): '.png', '').replace('Side_', ''), rarity=data['energy_skill_rank'][0]['rarity'], value=data['energy_skill_rank'][0]['value']) - if 'floors' in data and data['floors']: + info.total_star = 0 for floor in data['floors']: floor_info = FloorInfo(index=floor['index'], is_unlock=floor['is_unlock'], @@ -237,6 +244,8 @@ class AbyssInfo(Model): floor_info.end_times_up = end_times_up floor_info.end_times_down = end_times_down info.floors[floor['index']] = floor_info + if floor['index'] in ['9', '10', '11', '12']: + info.total_star += sum(l['star'] for l in floor['levels']) info.update_time = datetime.datetime.now() await info.save() diff --git a/LittlePaimon/plugins/Genshin_AIVoice/__init__.py b/LittlePaimon/plugins/Genshin_AIVoice/__init__.py index 8e3ade0..80023b0 100644 --- a/LittlePaimon/plugins/Genshin_AIVoice/__init__.py +++ b/LittlePaimon/plugins/Genshin_AIVoice/__init__.py @@ -30,8 +30,9 @@ CHARA_RE = '|'.join(SUPPORTS_CHARA) def is_paimon(event: Union[GroupMessageEvent, PrivateMessageEvent], state: T_State) -> bool: - if '_matched_dict' in state and not state['_matched_dict']['chara'] and event.to_me: - state['_matched_dict']['chara'] = '派蒙' + if '_matched_dict' in state: + if not state['_matched_dict']['chara'] and event.to_me: + state['_matched_dict']['chara'] = '派蒙' return True return False