mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 04:45:27 +00:00
🎨 black code
This commit is contained in:
parent
aa890c539f
commit
c7b0f530f7
@ -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 ''}"
|
||||
)
|
||||
|
@ -145,7 +145,7 @@ class Gacha(Plugin, BasePlugin):
|
||||
self.banner_cache.setdefault(gacha_base_info.gacha_id, banner)
|
||||
return banner
|
||||
|
||||
async def de_item_list(self,item_list: List[int]) -> List[dict]:
|
||||
async def de_item_list(self, item_list: List[int]) -> List[dict]:
|
||||
gacha_item: List[dict] = []
|
||||
for item_id in item_list:
|
||||
if 10000 <= item_id <= 100000:
|
||||
|
@ -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 解析成功")
|
||||
|
@ -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")
|
||||
|
@ -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:
|
||||
|
@ -174,11 +174,11 @@ async def execute(command, pass_error=True):
|
||||
|
||||
|
||||
async def async_re_sub(
|
||||
pattern: str | Pattern,
|
||||
repl: str | Callable[[Match], str] | Callable[[Match], Awaitable[str]],
|
||||
string: str,
|
||||
count: int = 0,
|
||||
flags: int = 0,
|
||||
pattern: str | Pattern,
|
||||
repl: str | Callable[[Match], str] | Callable[[Match], Awaitable[str]],
|
||||
string: str,
|
||||
count: int = 0,
|
||||
flags: int = 0,
|
||||
) -> str:
|
||||
"""
|
||||
一个支持 repl 参数为 async 函数的 re.sub
|
||||
@ -205,7 +205,7 @@ async def async_re_sub(
|
||||
# noinspection PyCallingNonCallable
|
||||
replaced = repl(match)
|
||||
result += temp[: match.span(1)[0]] + (replaced or repl)
|
||||
temp = temp[match.span(1)[1]:]
|
||||
temp = temp[match.span(1)[1] :]
|
||||
else:
|
||||
while match := re.search(pattern, temp, flags=flags):
|
||||
replaced = None
|
||||
@ -216,5 +216,5 @@ async def async_re_sub(
|
||||
# noinspection PyCallingNonCallable
|
||||
replaced = repl(match)
|
||||
result += temp[: match.span(1)[0]] + (replaced or repl)
|
||||
temp = temp[match.span(1)[1]:]
|
||||
temp = temp[match.span(1)[1] :]
|
||||
return result + temp
|
||||
|
Loading…
Reference in New Issue
Block a user