mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +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):
|
def get_ds(ds_type: str = None, new_ds: bool = False, data: Any = None, params: Optional[Mapping[str, Any]] = None):
|
||||||
"""DS 算法
|
"""DS 算法
|
||||||
|
|
||||||
代码来自 https://github.com/y1ndan/genshinhelper
|
代码来自 https://github.com/y1ndan/genshinhelper
|
||||||
:param ds_type: 1:ios 2:android 4:pc web 5:mobile web
|
:param ds_type: 1:ios 2:android 4:pc web 5:mobile web
|
||||||
:param new_ds: 是否为DS2算法
|
: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():
|
def new():
|
||||||
t = str(int(time.time()))
|
t = str(int(time.time()))
|
||||||
r = str(random.randint(100001, 200000)) # nosec
|
r = str(random.randint(100001, 200000)) # nosec
|
||||||
b = json.dumps(data) if data else ''
|
b = json.dumps(data) if data else ""
|
||||||
q = "&".join(f"{k}={v}" for k, v in sorted(params.items())) if params 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}')
|
c = hex_digest(f"salt={salt}&t={t}&r={r}&b={b}&q={q}")
|
||||||
return f'{t},{r},{c}'
|
return f"{t},{r},{c}"
|
||||||
|
|
||||||
def old():
|
def old():
|
||||||
t = str(int(time.time()))
|
t = str(int(time.time()))
|
||||||
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
|
r = "".join(random.sample(string.ascii_lowercase + string.digits, 6))
|
||||||
c = hex_digest(f'salt={salt}&t={t}&r={r}')
|
c = hex_digest(f"salt={salt}&t={t}&r={r}")
|
||||||
return f'{t},{r},{c}'
|
return f"{t},{r},{c}"
|
||||||
|
|
||||||
app_version = '2.36.1'
|
app_version = "2.36.1"
|
||||||
client_type = '5'
|
client_type = "5"
|
||||||
salt = 'YVEIkzDFNHLeKXLxzqCA9TzxCpWwbIbk'
|
salt = "YVEIkzDFNHLeKXLxzqCA9TzxCpWwbIbk"
|
||||||
ds = old()
|
ds = old()
|
||||||
if ds_type in ('android', '2'):
|
if ds_type in ("android", "2"):
|
||||||
app_version = '2.36.1'
|
app_version = "2.36.1"
|
||||||
client_type = '2'
|
client_type = "2"
|
||||||
salt = 'n0KjuIrKgLHh08LWSCYP0WXlVXaYvV64'
|
salt = "n0KjuIrKgLHh08LWSCYP0WXlVXaYvV64"
|
||||||
ds = old()
|
ds = old()
|
||||||
if ds_type == 'android_new':
|
if ds_type == "android_new":
|
||||||
app_version = '2.36.1'
|
app_version = "2.36.1"
|
||||||
client_type = '2'
|
client_type = "2"
|
||||||
salt = 't0qEgfub6cvueAPgR5m9aQWWVciEer7v'
|
salt = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"
|
||||||
ds = new()
|
ds = new()
|
||||||
if new_ds:
|
if new_ds:
|
||||||
app_version = '2.36.1'
|
app_version = "2.36.1"
|
||||||
client_type = '5'
|
client_type = "5"
|
||||||
salt = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
|
salt = "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs"
|
||||||
ds = new()
|
ds = new()
|
||||||
|
|
||||||
return app_version, client_type, ds
|
return app_version, client_type, ds
|
||||||
@ -86,5 +87,5 @@ def get_ua(device: str = "Paimon Build", version: str = "2.36.1"):
|
|||||||
return (
|
return (
|
||||||
f"Mozilla/5.0 (Linux; Android 12; {device}; wv) "
|
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 "
|
"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)
|
self.banner_cache.setdefault(gacha_base_info.gacha_id, banner)
|
||||||
return 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] = []
|
gacha_item: List[dict] = []
|
||||||
for item_id in item_list:
|
for item_id in item_list:
|
||||||
if 10000 <= item_id <= 100000:
|
if 10000 <= item_id <= 100000:
|
||||||
|
@ -109,7 +109,7 @@ class SignSystem:
|
|||||||
data = resp.json()
|
data = resp.json()
|
||||||
status = data.get("status")
|
status = data.get("status")
|
||||||
if status != 0:
|
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:
|
if data.get("code", 0) != 0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
logger.info("recognize 解析成功")
|
logger.info("recognize 解析成功")
|
||||||
|
@ -55,7 +55,9 @@ class WebApp(Plugin):
|
|||||||
if web_app_data:
|
if web_app_data:
|
||||||
logger.info("用户 %s[%s] 触发 WEB_APP_DATA 请求", user.full_name, user.id)
|
logger.info("用户 %s[%s] 触发 WEB_APP_DATA 请求", user.full_name, user.id)
|
||||||
result = self.de_web_app_data(web_app_data.data)
|
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.code == 0:
|
||||||
if result.path == "verify":
|
if result.path == "verify":
|
||||||
validate = result.data.get("geetest_validate")
|
validate = result.data.get("geetest_validate")
|
||||||
|
@ -128,7 +128,9 @@ def error_callable(func: Callable) -> Callable:
|
|||||||
logger.error("GenshinException")
|
logger.error("GenshinException")
|
||||||
logger.exception(exc)
|
logger.exception(exc)
|
||||||
await send_user_notification(
|
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
|
return ConversationHandler.END
|
||||||
except ReturnCodeError as exc:
|
except ReturnCodeError as exc:
|
||||||
|
@ -174,11 +174,11 @@ async def execute(command, pass_error=True):
|
|||||||
|
|
||||||
|
|
||||||
async def async_re_sub(
|
async def async_re_sub(
|
||||||
pattern: str | Pattern,
|
pattern: str | Pattern,
|
||||||
repl: str | Callable[[Match], str] | Callable[[Match], Awaitable[str]],
|
repl: str | Callable[[Match], str] | Callable[[Match], Awaitable[str]],
|
||||||
string: str,
|
string: str,
|
||||||
count: int = 0,
|
count: int = 0,
|
||||||
flags: int = 0,
|
flags: int = 0,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
一个支持 repl 参数为 async 函数的 re.sub
|
一个支持 repl 参数为 async 函数的 re.sub
|
||||||
@ -205,7 +205,7 @@ async def async_re_sub(
|
|||||||
# noinspection PyCallingNonCallable
|
# noinspection PyCallingNonCallable
|
||||||
replaced = repl(match)
|
replaced = repl(match)
|
||||||
result += temp[: match.span(1)[0]] + (replaced or repl)
|
result += temp[: match.span(1)[0]] + (replaced or repl)
|
||||||
temp = temp[match.span(1)[1]:]
|
temp = temp[match.span(1)[1] :]
|
||||||
else:
|
else:
|
||||||
while match := re.search(pattern, temp, flags=flags):
|
while match := re.search(pattern, temp, flags=flags):
|
||||||
replaced = None
|
replaced = None
|
||||||
@ -216,5 +216,5 @@ async def async_re_sub(
|
|||||||
# noinspection PyCallingNonCallable
|
# noinspection PyCallingNonCallable
|
||||||
replaced = repl(match)
|
replaced = repl(match)
|
||||||
result += temp[: match.span(1)[0]] + (replaced or repl)
|
result += temp[: match.span(1)[0]] + (replaced or repl)
|
||||||
temp = temp[match.span(1)[1]:]
|
temp = temp[match.span(1)[1] :]
|
||||||
return result + temp
|
return result + temp
|
||||||
|
Loading…
Reference in New Issue
Block a user