diff --git a/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py b/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py index 3b84aee..76847c9 100644 --- a/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py +++ b/hoshino/modules/Genshin_Paimon/abyss_info/__init__.py @@ -1,6 +1,4 @@ -import json,os,re -from hoshino import R,MessageSegment,logger, Service -from hoshino.typing import CQEvent, Message +from hoshino import logger, Service from ..util import get_uid_in_msg from ..get_data import get_abyss_data from .get_img import draw_abyss_card @@ -33,8 +31,17 @@ async def main(bot,ev): else: abyss_card = await draw_abyss_card(data, uid, true_floor) await bot.send(ev, abyss_card, at_sender=True) + except ActionFailed: + logger.exception('账号可能被风控') + await bot.send(ev, '派蒙可能被风控,发不出消息') + except TypeError or AttributeError: + await bot.send(ev, '派蒙好像没有该UID的绑定信息') + except IndexError or KeyError: + await bot.send(ev, '派蒙获取信息失败,可能是米游社API有变动,请联系开发者') + except JSONDecodeError: + await bot.send(ev, '派蒙获取信息失败,重试一下吧') except Exception as e: - await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True) + await bot.send(ev, f'派蒙出现了问题:{e}') diff --git a/hoshino/modules/Genshin_Paimon/config.py b/hoshino/modules/Genshin_Paimon/config.py index 4b1dbd8..f897c54 100644 --- a/hoshino/modules/Genshin_Paimon/config.py +++ b/hoshino/modules/Genshin_Paimon/config.py @@ -5,8 +5,12 @@ remind_time_end = 8 # 树脂提醒检查时间,8即为每八分钟检查一次 remind_check_time = 8 +# 树脂提醒的每日上限次数,3即为每天最多提醒3次 +remind_limit_count = 3 + # 自动签到执行开始时间,0即为每天0点执行 auto_sign_time = 0 + # 模拟抽卡的冷却时间,单位秒 gacha_cooldown = 30 diff --git a/hoshino/modules/Genshin_Paimon/daily_note/__init__.py b/hoshino/modules/Genshin_Paimon/daily_note/__init__.py index a88e6e1..a3d7cf1 100644 --- a/hoshino/modules/Genshin_Paimon/daily_note/__init__.py +++ b/hoshino/modules/Genshin_Paimon/daily_note/__init__.py @@ -1,13 +1,12 @@ import re -from hoshino import Service +from hoshino import Service,get_bot, logger from ..util import get_uid_in_msg from ..get_data import get_daily_note_data from .get_img import draw_daily_note_card from ..db_util import update_note_remind2, update_note_remind, get_note_remind, delete_note_remind, update_day_remind_count -from hoshino import get_bot, logger from datetime import datetime, timedelta from asyncio import sleep -from ..config import remind_time_start, remind_time_end, remind_check_time +from ..config import remind_time_start, remind_time_end, remind_check_time, remind_limit_count help_msg=''' [ssbq/实时便签 (uid)]查询当前树脂、洞天宝钱、派遣状况等 @@ -49,8 +48,17 @@ async def main(bot,ev): else: daily_note_card = await draw_daily_note_card(data, uid) await bot.send(ev, daily_note_card, at_sender=True) + except ActionFailed: + logger.exception('账号可能被风控') + await bot.send(ev, '派蒙可能被风控,发不出消息') + except TypeError or AttributeError: + await bot.send(ev, '派蒙好像没有该UID的绑定信息') + except IndexError or KeyError: + await bot.send(ev, '派蒙获取信息失败,可能是米游社API有变动,请联系开发者') + except JSONDecodeError: + await bot.send(ev, '派蒙获取信息失败,重试一下吧') except Exception as e: - await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True) + await bot.send(ev, f'派蒙出现了问题:{e}') @sv.scheduled_job('cron', minute=f'*/{remind_check_time}') async def check_note(): @@ -71,7 +79,7 @@ async def check_note(): time_e = False else: time_e = True - if enable and ((today_remind_count and today_remind_count < 3) or not today_remind_count) and time_e: + if enable and ((today_remind_count and today_remind_count < remind_limit_count) or not today_remind_count) and time_e: now_data = await get_daily_note_data(uid) if isinstance(now_data, str): try: diff --git a/hoshino/modules/Genshin_Paimon/gacha/__init__.py b/hoshino/modules/Genshin_Paimon/gacha/__init__.py index b17ecbb..602bd08 100644 --- a/hoshino/modules/Genshin_Paimon/gacha/__init__.py +++ b/hoshino/modules/Genshin_Paimon/gacha/__init__.py @@ -196,24 +196,24 @@ async def getdg_weapon(): return weapon_up_list def gacha_type_by_name(gacha_type): - # if re.match(r'^角色1|限定1|角色2|限定2(?:池)$', gacha_type): - # return 301 - if re.match(r'^角色1|限定1(?:池)$', gacha_type): + if re.match(r'^角色1|限定1|角色2|限定2(?:池)$', gacha_type): return 301 - if re.match(r'^角色2|限定2(?:池)$', gacha_type): - return 400 + # if re.match(r'^角色1|限定1(?:池)$', gacha_type): + # return 301 + # if re.match(r'^角色2|限定2(?:池)$', gacha_type): + # return 400 if re.match(r'^武器|武器池$', gacha_type): return 302 if re.match(r'^常驻|普(?:池)$', gacha_type): return 200 - # if re.match(r'^新角色|新限定(?:池)$', gacha_type): - # return 'role_1_pool' + if re.match(r'^新角色1|新限定1|新角色2|新限定2(?:池)$', gacha_type): + return 'role_1_pool' if re.match(r'^彩蛋池?$', gacha_type): return 'all_star' - if re.match(r'^新角色1|新限定1(?:池)$', gacha_type): - return 'role_1_pool' - if re.match(r'^新角色2|新限定2(?:池)$', gacha_type): - return 'role_2_pool' + # if re.match(r'^新角色1|新限定1(?:池)$', gacha_type): + # return 'role_1_pool' + # if re.match(r'^新角色2|新限定2(?:池)$', gacha_type): + # return 'role_2_pool' if re.match(r'^新武器|新武器池$', gacha_type): return 'weapon_pool' return 0 diff --git a/hoshino/modules/Genshin_Paimon/get_data.py b/hoshino/modules/Genshin_Paimon/get_data.py index c3ddf74..ef61c1a 100644 --- a/hoshino/modules/Genshin_Paimon/get_data.py +++ b/hoshino/modules/Genshin_Paimon/get_data.py @@ -176,8 +176,10 @@ async def sign(uid): 'region': server_id } res = await aiorequests.post(url=url, headers=headers, json=json_data) - data = await res.json() - print(res) + try: + data = await res.json() + except: + return await res.text if await check_retcode(data, cookie, uid): return data else: diff --git a/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py b/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py index d269f31..2980138 100644 --- a/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py +++ b/hoshino/modules/Genshin_Paimon/monthinfo/__init__.py @@ -1,5 +1,5 @@ -import json,os,re,datetime -from hoshino import R,MessageSegment,logger, Service +import re, datetime +from hoshino import logger, Service from hoshino.util import filt_message from ..util import get_uid_in_msg from ..get_data import get_monthinfo_data @@ -32,5 +32,14 @@ async def main(bot,ev): else: monthinfo_card = await draw_monthinfo_card(data) await bot.send(ev, monthinfo_card, at_sender=True) + except ActionFailed: + logger.exception('账号可能被风控') + await bot.send(ev, '派蒙可能被风控,发不出消息') + except TypeError or AttributeError: + await bot.send(ev, '派蒙好像没有该UID的绑定信息') + except IndexError or KeyError: + await bot.send(ev, '派蒙获取信息失败,可能是米游社API有变动,请联系开发者') + except JSONDecodeError: + await bot.send(ev, '派蒙获取信息失败,重试一下吧') except Exception as e: - await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True) + await bot.send(ev, f'派蒙出现了问题:{e}') diff --git a/hoshino/modules/Genshin_Paimon/player_card/__init__.py b/hoshino/modules/Genshin_Paimon/player_card/__init__.py index de44d52..017c189 100644 --- a/hoshino/modules/Genshin_Paimon/player_card/__init__.py +++ b/hoshino/modules/Genshin_Paimon/player_card/__init__.py @@ -1,6 +1,4 @@ -import json,os,re -from hoshino import R,MessageSegment,logger, Service -from hoshino.typing import CQEvent, Message +from hoshino import logger, Service from hoshino.util import filt_message from ..util import get_uid_in_msg, get_at_target from ..get_data import get_player_card_data, get_chara_detail_data, get_chara_skill_data @@ -35,8 +33,16 @@ async def player_card(bot,ev): chara_data = None if isinstance(chara_data, str) else chara_data player_card = await draw_player_card(data, chara_data, uid, nickname) await bot.send(ev, player_card, at_sender=True) + except ActionFailed: + await bot.send(ev, '派蒙可能被风控,发不出消息') + except TypeError or AttributeError: + await bot.send(ev, '派蒙好像没有该UID的绑定信息') + except IndexError or KeyError: + await bot.send(ev, '派蒙获取信息失败,可能是米游社API有变动,请联系开发者') + except JSONDecodeError: + await bot.send(ev, '派蒙获取信息失败,重试一下吧') except Exception as e: - await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True) + await bot.send(ev, f'派蒙出现了问题:{e}') @sv.on_prefix('ysa') async def all_characters(bot,ev): @@ -51,8 +57,16 @@ async def all_characters(bot,ev): else: player_card = await draw_all_chara_card(chara_data, uid) await bot.send(ev, player_card, at_sender=True) + except ActionFailed: + await bot.send(ev, '派蒙可能被风控,发不出消息') + except TypeError or AttributeError: + await bot.send(ev, '派蒙好像没有该UID的绑定信息') + except IndexError or KeyError: + await bot.send(ev, '派蒙获取信息失败,可能是米游社API有变动,请联系开发者') + except JSONDecodeError: + await bot.send(ev, '派蒙获取信息失败,重试一下吧') except Exception as e: - await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True) + await bot.send(ev, f'派蒙出现了问题:{e}') @sv.on_prefix('ysc') async def my_characters(bot,ev): @@ -76,6 +90,15 @@ async def my_characters(bot,ev): skill_data = await get_chara_skill_data(uid, chara_name[0], use_cache=use_cache) chara_card = await draw_chara_card(chara_data, skill_data, chara_name, uid) await bot.send(ev, chara_card, at_sender=True) + except ActionFailed: + logger.exception('账号可能被风控') + await bot.send(ev, '派蒙可能被风控,发不出消息') + except TypeError or AttributeError: + await bot.send(ev, '派蒙好像没有该UID的绑定信息') + except IndexError or KeyError: + await bot.send(ev, '派蒙获取信息失败,可能是米游社API有变动,请联系开发者') + except JSONDecodeError: + await bot.send(ev, '派蒙获取信息失败,重试一下吧') except Exception as e: - await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True) + await bot.send(ev, f'派蒙出现了问题:{e}') diff --git a/hoshino/modules/Genshin_Paimon/user_data/__init__.py b/hoshino/modules/Genshin_Paimon/user_data/__init__.py index 9e02ec3..08bf96a 100644 --- a/hoshino/modules/Genshin_Paimon/user_data/__init__.py +++ b/hoshino/modules/Genshin_Paimon/user_data/__init__.py @@ -1,6 +1,4 @@ -from hoshino import MessageSegment, Service, trigger, priv, CanceledException,logger -from hoshino.typing import CQEvent, Message -from nonebot import message_preprocessor +from hoshino import Service, priv, CanceledException, logger from ..get_data import get_bind_game from ..db_util import insert_public_cookie, update_private_cookie, delete_cookie_cache, delete_cookie, delete_private_cookie,update_last_query, reset_public_cookie from ..util import check_cookie