🎨 black code

This commit is contained in:
洛水居室 2022-11-23 09:11:29 +08:00
parent aa890c539f
commit c7b0f530f7
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
6 changed files with 38 additions and 33 deletions

View File

@ -29,6 +29,7 @@ def hex_digest(text):
def get_ds(ds_type: str = None, new_ds: bool = False, data: Any = None, params: Optional[Mapping[str, Any]] = None):
"""DS 算法
代码来自 https://github.com/y1ndan/genshinhelper
:param ds_type: 1:ios 2:android 4:pc web 5:mobile web
:param new_ds: 是否为DS2算法
@ -40,35 +41,35 @@ def get_ds(ds_type: str = None, new_ds: bool = False, data: Any = None, params:
def new():
t = str(int(time.time()))
r = str(random.randint(100001, 200000)) # nosec
b = json.dumps(data) if data else ''
q = "&".join(f"{k}={v}" for k, v in sorted(params.items())) if params else ''
c = hex_digest(f'salt={salt}&t={t}&r={r}&b={b}&q={q}')
return f'{t},{r},{c}'
b = json.dumps(data) if data else ""
q = "&".join(f"{k}={v}" for k, v in sorted(params.items())) if params else ""
c = hex_digest(f"salt={salt}&t={t}&r={r}&b={b}&q={q}")
return f"{t},{r},{c}"
def old():
t = str(int(time.time()))
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
c = hex_digest(f'salt={salt}&t={t}&r={r}')
return f'{t},{r},{c}'
r = "".join(random.sample(string.ascii_lowercase + string.digits, 6))
c = hex_digest(f"salt={salt}&t={t}&r={r}")
return f"{t},{r},{c}"
app_version = '2.36.1'
client_type = '5'
salt = 'YVEIkzDFNHLeKXLxzqCA9TzxCpWwbIbk'
app_version = "2.36.1"
client_type = "5"
salt = "YVEIkzDFNHLeKXLxzqCA9TzxCpWwbIbk"
ds = old()
if ds_type in ('android', '2'):
app_version = '2.36.1'
client_type = '2'
salt = 'n0KjuIrKgLHh08LWSCYP0WXlVXaYvV64'
if ds_type in ("android", "2"):
app_version = "2.36.1"
client_type = "2"
salt = "n0KjuIrKgLHh08LWSCYP0WXlVXaYvV64"
ds = old()
if ds_type == 'android_new':
app_version = '2.36.1'
client_type = '2'
salt = 't0qEgfub6cvueAPgR5m9aQWWVciEer7v'
if ds_type == "android_new":
app_version = "2.36.1"
client_type = "2"
salt = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"
ds = new()
if new_ds:
app_version = '2.36.1'
client_type = '5'
salt = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
app_version = "2.36.1"
client_type = "5"
salt = "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs"
ds = new()
return app_version, client_type, ds
@ -86,5 +87,5 @@ def get_ua(device: str = "Paimon Build", version: str = "2.36.1"):
return (
f"Mozilla/5.0 (Linux; Android 12; {device}; wv) "
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36 "
f"miHoYoBBS/{version}"
f"{'miHoYoBBS/'+version if version else ''}"
)

View File

@ -109,7 +109,7 @@ class SignSystem:
data = resp.json()
status = data.get("status")
if status != 0:
logger.error("recognize 解析错误:[%s]%s", data.get('code'), data.get('msg'))
logger.error("recognize 解析错误:[%s]%s", data.get("code"), data.get("msg"))
if data.get("code", 0) != 0:
raise RuntimeError
logger.info("recognize 解析成功")

View File

@ -55,7 +55,9 @@ class WebApp(Plugin):
if web_app_data:
logger.info("用户 %s[%s] 触发 WEB_APP_DATA 请求", user.full_name, user.id)
result = self.de_web_app_data(web_app_data.data)
logger.debug("path[%s]\ndata[%s]\ncode[%s]\nmessage[%s]", result.path, result.data, result.code, result.message)
logger.debug(
"path[%s]\ndata[%s]\ncode[%s]\nmessage[%s]", result.path, result.data, result.code, result.message
)
if result.code == 0:
if result.path == "verify":
validate = result.data.get("geetest_validate")

View File

@ -128,7 +128,9 @@ def error_callable(func: Callable) -> Callable:
logger.error("GenshinException")
logger.exception(exc)
await send_user_notification(
update, context, f"出错了呜呜呜 ~ 获取账号信息发生错误 错误信息为 {exc.original if exc.original else exc.retcode} ~ 请稍后再试"
update,
context,
f"出错了呜呜呜 ~ 获取账号信息发生错误 错误信息为 {exc.original if exc.original else exc.retcode} ~ 请稍后再试",
)
return ConversationHandler.END
except ReturnCodeError as exc: