diff --git a/Paimon_Gacha_Log/__init__.py b/Paimon_Gacha_Log/__init__.py index ffc998d..29f6122 100644 --- a/Paimon_Gacha_Log/__init__.py +++ b/Paimon_Gacha_Log/__init__.py @@ -53,16 +53,19 @@ async def ckjl(bot: Bot, event: Union[MessageEvent, GroupMessageEvent], msg: Mes @gacha_log_update.handle() async def update_ckjl(event: MessageEvent, msg: Message = CommandArg()): + url = None + if msg: + msg = str(msg) + match = re.search(r'(https://webstatic.mihoyo.com/.*#/log)', msg) + if match: + url = match.group(1) + msg = msg.replace(url, '') uid, msg, user_id, use_cache = await get_uid_in_msg(event, msg) if not uid: await gacha_log_update.finish('请把uid给派蒙哦,比如获取抽卡记录100000001 链接', at_sender=True) - if msg: - match = re.search(r'(https://webstatic.mihoyo.com/.*#/log)', msg) - if match: - url = str(match.group(1)) - else: - await gacha_log_update.finish('你这个抽卡链接不对哦,应该是以https://开头、#/log结尾的!', at_sender=True) - else: + if msg and not url: + await gacha_log_update.finish('你这个抽卡链接不对哦,应该是以https://开头、#/log结尾的!', at_sender=True) + if not msg and not url: with open(os.path.join(data_path, 'user_gacha_log.json'), 'r', encoding="utf-8") as f: user_data = json.load(f) if user_id in user_data and uid in user_data[user_id]: diff --git a/Paimon_Gacha_Log/api.py b/Paimon_Gacha_Log/api.py index 58a3f40..949d65c 100644 --- a/Paimon_Gacha_Log/api.py +++ b/Paimon_Gacha_Log/api.py @@ -32,14 +32,12 @@ async def checkApi(url): try: async with ClientSession() as session: r = await session.get(url) - s = (await r.read()).decode("utf-8") - j = json.loads(s) + j = await r.json() except Exception as e: - # print("API请求解析出错:\n", traceback.format_exc()) return f'API请求解析出错:{e}' if not j["data"]: - if j["message"] == "authkey valid error": + if j["message"] == "authkey error": return "authkey错误,请重新获取链接给派蒙!" elif j["message"] == "authkey timeout": return "authkey已过期,请重新获取链接给派蒙!" diff --git a/Paimon_Gacha_Log/gacha_logs.py b/Paimon_Gacha_Log/gacha_logs.py index d2d3f73..cc7e89e 100644 --- a/Paimon_Gacha_Log/gacha_logs.py +++ b/Paimon_Gacha_Log/gacha_logs.py @@ -18,8 +18,7 @@ async def getGachaLogs(url, gachaTypeId): api = getApi(url, gachaTypeId, size, page, end_id) async with ClientSession() as session: r = await session.get(api) - s = (await r.read()).decode("utf-8") - j = json.loads(s) + j = await r.json() gacha = j["data"]["list"] if not len(gacha): break @@ -53,7 +52,6 @@ def mergeDataFunc(localData, gachaData): if flaglist[i] == 0: gachaGet = bannerGet[i] tempData.insert(0, gachaGet) - # print("追加", len(tempData), "条记录", flush=True) for i in tempData: localData["gachaLog"][banner].insert(0, i) diff --git a/Paimon_Plugins/chat.py b/Paimon_Plugins/chat.py index 0d7c9d8..75297ce 100644 --- a/Paimon_Plugins/chat.py +++ b/Paimon_Plugins/chat.py @@ -39,7 +39,7 @@ chat_lmt = FreqLimiter2(60) def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, responses): - hammer = on_regex(pattern, priority=14, temp=True) + hammer = on_regex(pattern, priority=10) @hammer.handle() async def handler(event: GroupMessageEvent):