From 9c6008767314c4ea06ef063dcb8f2fc2e1b605c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sun, 13 Nov 2022 01:33:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20`User-Agent`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/apihelper/hyperion.py | 2 +- plugins/genshin/sign.py | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/apihelper/hyperion.py b/modules/apihelper/hyperion.py index 26229d2..95b7bdf 100644 --- a/modules/apihelper/hyperion.py +++ b/modules/apihelper/hyperion.py @@ -369,7 +369,7 @@ class Verification: USER_AGENT = ( "User-Agent: Mozilla/5.0 (Linux; Android 12; Mi 10 Build/SKQ1.211006.001; wv) " "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36 " - "miHoYoBBS/2.33.1" + "miHoYoBBS/2.36.1" ) BBS_HEADERS = { "Accept": "application/json, text/plain, */*", diff --git a/plugins/genshin/sign.py b/plugins/genshin/sign.py index 14a957c..64e7f80 100644 --- a/plugins/genshin/sign.py +++ b/plugins/genshin/sign.py @@ -69,8 +69,7 @@ class SignSystem: } async def get_challenge_button( - self, uid: int, user_id: int, gt: Optional[str] = None, challenge: Optional[str] = None, - callback: bool = True + self, uid: int, user_id: int, gt: Optional[str] = None, challenge: Optional[str] = None, callback: bool = True ) -> Optional[InlineKeyboardMarkup]: if not config.pass_challenge_user_web: return None @@ -105,8 +104,8 @@ class SignSystem: header = { "Accept": "*/*", "X-Requested-With": "com.mihoyo.hyperion", - "User-Agent": "Mozilla/5.0 (Linux; Android 12; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) " - "Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36 miHoYoBBS/2.37.1", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/107.0.0.0 Safari/537.36", "Referer": referer, "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", } @@ -129,7 +128,7 @@ class SignSystem: timeout=30, ) text = req.text - logger.debug(f"ajax 返回:{text}") + logger.debug(f"ajax 返回:%s", text) if req.status_code != 200: raise RuntimeError text = re.findall(r"^.*?\((\{.*?)\)$", text)[0] @@ -169,11 +168,11 @@ class SignSystem: params=pass_challenge_params, timeout=60, ) - logger.debug(f"签到 recognize 请求返回:{resp.text}") + logger.debug(f"签到 recognize 请求返回:%s", resp.text) data = resp.json() status = data.get("status") if status is not None and status != 0: - logger.error(f"签到 recognize 请求解析错误:{data.get('msg')}") + logger.error(f"签到 recognize 请求解析错误:[%s]%s", data.get('code'), data.get('msg')) if data.get("code", 0) != 0: raise RuntimeError logger.info("签到 recognize 请求 解析成功") @@ -389,11 +388,7 @@ class Sign(Plugin, BasePlugin): await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons)) except NeedChallenge as exc: button = await self.system.get_challenge_button( - exc.uid, - user.id, - exc.gt, - exc.challenge, - not filters.ChatType.PRIVATE.filter(message) + exc.uid, user.id, exc.gt, exc.challenge, not filters.ChatType.PRIVATE.filter(message) ) reply_message = await message.reply_text( f"UID {exc.uid} 签到失败,触发验证码风控,请尝试点击下方按钮重新签到", allow_sending_without_reply=True, reply_markup=button