From 957473e2ce8fc996c449d21ff96912bebf405f96 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Tue, 26 Apr 2022 18:50:56 +0800 Subject: [PATCH] fix bugs --- .../Genshin_Paimon/abyss_info/__init__.py | 1 + .../Genshin_Paimon/daily_note/__init__.py | 1 + .../Genshin_Paimon/monthinfo/__init__.py | 1 + .../Genshin_Paimon/mys_bbs_sign/__init__.py | 6 +++++- .../Genshin_Paimon/player_card/__init__.py | 1 + .../Genshin_Paimon/player_card/get_img.py | 19 +++++++++++-------- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py b/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py index 5aeea67..e6e48bc 100644 --- a/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py +++ b/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py @@ -1,5 +1,6 @@ from hoshino import logger, Service from aiocqhttp.exceptions import ActionFailed +from json import JSONDecodeError from ..util import get_uid_in_msg from ..get_data import get_abyss_data from .get_img import draw_abyss_card diff --git a/hoshino/modules/Genshin_Paimon/daily_note/__init__.py b/hoshino/modules/Genshin_Paimon/daily_note/__init__.py index 1faf5bb..61e6b31 100644 --- a/hoshino/modules/Genshin_Paimon/daily_note/__init__.py +++ b/hoshino/modules/Genshin_Paimon/daily_note/__init__.py @@ -1,5 +1,6 @@ import re from aiocqhttp.exceptions import ActionFailed +from json import JSONDecodeError from hoshino import Service,get_bot, logger from ..util import get_uid_in_msg from ..get_data import get_daily_note_data diff --git a/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py b/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py index 8b2583b..0cfbab7 100644 --- a/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py +++ b/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py @@ -1,5 +1,6 @@ import re, datetime from aiocqhttp.exceptions import ActionFailed +from json import JSONDecodeError from hoshino import logger, Service from hoshino.util import filt_message from ..util import get_uid_in_msg diff --git a/hoshino/modules/Genshin_Paimon/mys_bbs_sign/__init__.py b/hoshino/modules/Genshin_Paimon/mys_bbs_sign/__init__.py index d8acb5a..6a1bb7f 100644 --- a/hoshino/modules/Genshin_Paimon/mys_bbs_sign/__init__.py +++ b/hoshino/modules/Genshin_Paimon/mys_bbs_sign/__init__.py @@ -1,6 +1,6 @@ from hoshino import Service, get_bot, logger from ..util import get_uid_in_msg -from ..db_util import get_auto_sign, add_auto_sign, delete_auto_sign +from ..db_util import get_auto_sign, add_auto_sign, delete_auto_sign, get_private_cookie from ..get_data import get_sign_info, sign, get_sign_list from ..config import auto_sign_time from datetime import datetime @@ -44,6 +44,10 @@ async def bbs_auto_sign(bot, ev): find_action = re.search(r'(?P开启|启用|打开|关闭|禁用)', msg) if find_action: if find_action.group('action') in ['开启', '启用', '打开']: + cookie = await get_private_cookie(uid, key='uid') + if not cookie: + await bot.send(ev, '你的该uid还没绑定cookie哦,先用ysb绑定吧!', at_sender=True) + return await add_auto_sign(str(ev.user_id), uid, str(ev.group_id)) await bot.send(ev, '开启米游社自动签到成功,派蒙会在每日0点帮你签到', at_sender=True) elif find_action.group('action') in ['关闭', '禁用']: diff --git a/hoshino/modules/Genshin_Paimon/player_card/__init__.py b/hoshino/modules/Genshin_Paimon/player_card/__init__.py index 4989711..e631400 100644 --- a/hoshino/modules/Genshin_Paimon/player_card/__init__.py +++ b/hoshino/modules/Genshin_Paimon/player_card/__init__.py @@ -1,4 +1,5 @@ from aiocqhttp.exceptions import ActionFailed +from json import JSONDecodeError from hoshino import logger, Service from hoshino.util import filt_message from ..util import get_uid_in_msg, get_at_target diff --git a/hoshino/modules/Genshin_Paimon/player_card/get_img.py b/hoshino/modules/Genshin_Paimon/player_card/get_img.py index f89907d..eeca1ac 100644 --- a/hoshino/modules/Genshin_Paimon/player_card/get_img.py +++ b/hoshino/modules/Genshin_Paimon/player_card/get_img.py @@ -4,6 +4,7 @@ from ..util import pil2b64 from hoshino.typing import MessageSegment from hoshino import logger, aiorequests from io import BytesIO +import copy res_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'res') @@ -433,29 +434,31 @@ async def draw_chara_card(data, skill_data, chara_name, uid): i += 1 if not skill_data: - skill_data = {'retcode' : 'error'} + skill_data_ = {'retcode' : 'error'} + else: + skill_data_ = copy.deepcopy(skill_data) # 补上三命和五命的技能等级提升 - if skill_data['retcode'] == 0 and character['constellations'][2]['is_actived']: + if skill_data_['retcode'] == 0 and character['constellations'][2]['is_actived']: skill_name = re.search(r'>(.*)', character['constellations'][2]['effect']) if skill_name: skill_name = skill_name.group(1) - for skill in skill_data['data']['skill_list']: + for skill in skill_data_['data']['skill_list']: if skill['name'] == skill_name: skill['level_current'] += 3 - if skill_data['retcode'] == 0 and character['constellations'][4]['is_actived']: + if skill_data_['retcode'] == 0 and character['constellations'][4]['is_actived']: skill_name = re.search(r'>(.*)', character['constellations'][4]['effect']) if skill_name: skill_name = skill_name.group(1) - for skill in skill_data['data']['skill_list']: + for skill in skill_data_['data']['skill_list']: if skill['name'] == skill_name: skill['level_current'] += 3 # 天赋等级 i = 0 - if skill_data['retcode'] == 0: + if skill_data_['retcode'] == 0: skill_p = [(621, 98), (621, 168), (621, 238)] - skill_data_t = skill_data['data']['skill_list'] + skill_data_t = skill_data_['data']['skill_list'] for skill in skill_data_t[0:2]: skill_icon = await draw_const_skill_icon(skill, character['name']) bg_img.alpha_composite(skill_icon, skill_p[i]) @@ -473,7 +476,7 @@ async def draw_chara_card(data, skill_data, chara_name, uid): bg_draw.text((skill_p[i][0]+73+(6 if skill["level_current"] < 10 else 0),skill_p[i][1]+22), f'Lv.{skill["level_current"]}', font=get_font(18), fill='white') # 命座 i = 0 - if skill_data['retcode'] == 0: + if skill_data_['retcode'] == 0: const_p = [(669, 8), (734, 60), (757, 130), (757, 207), (734, 277), (669, 329)] else: const_p = [(626, 8), (691, 60), (714, 130), (714, 207), (691, 277), (626, 329)]