mirror of
https://github.com/baiqwerdvd/ArknightsUID.git
synced 2025-05-05 03:23:45 +08:00
🐛 修复arkmr报错
This commit is contained in:
parent
7386758016
commit
c1e2be7135
@ -45,7 +45,7 @@ async def get_ap_img(bot_id: str, user_id: str):
|
|||||||
if uid_list is None:
|
if uid_list is None:
|
||||||
return '请先绑定一个可用CRED & UID再来查询哦~'
|
return '请先绑定一个可用CRED & UID再来查询哦~'
|
||||||
for uid in uid_list:
|
for uid in uid_list:
|
||||||
status = await ark_skd_api.check_cred_valid(uid)
|
status = await ark_skd_api.check_cred_valid(uid=uid)
|
||||||
if status is not bool:
|
if status is not bool:
|
||||||
useable_uid_list.append(uid)
|
useable_uid_list.append(uid)
|
||||||
logger.info(f'[每日信息]可用UID: {useable_uid_list}')
|
logger.info(f'[每日信息]可用UID: {useable_uid_list}')
|
||||||
|
@ -19,7 +19,7 @@ async def deal_skd_cred(bot_id: str, cred: str, user_id: str) -> str:
|
|||||||
token = await ark_skd_api.refresh_token(match.group())
|
token = await ark_skd_api.refresh_token(match.group())
|
||||||
print(token)
|
print(token)
|
||||||
|
|
||||||
check_cred = await ark_skd_api.check_cred_valid(match.group(), token)
|
check_cred = await ark_skd_api.check_cred_valid(cred=match.group(), token=token)
|
||||||
|
|
||||||
if isinstance(check_cred, bool):
|
if isinstance(check_cred, bool):
|
||||||
return 'Cred无效!'
|
return 'Cred无效!'
|
||||||
|
@ -24,6 +24,18 @@ proxy_url = core_plugins_config.get_config('proxy').data
|
|||||||
ssl_verify = core_plugins_config.get_config('MhySSLVerify').data
|
ssl_verify = core_plugins_config.get_config('MhySSLVerify').data
|
||||||
|
|
||||||
|
|
||||||
|
_HEADER: dict[str, str] = {
|
||||||
|
'Host': 'zonai.skland.com',
|
||||||
|
'platform': '1',
|
||||||
|
'Origin': 'https://www.skland.com',
|
||||||
|
'Referer': 'https://www.skland.com/',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': 'Skland/1.1.0 (com.hypergryph.skland; build:100100047; Android 33; ) Okhttp/4.11.0',
|
||||||
|
'vName': '1.1.0',
|
||||||
|
'vCode': '100100047',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TokenExpiredError(Exception):
|
class TokenExpiredError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -34,16 +46,6 @@ class TokenRefreshFailed(Exception):
|
|||||||
|
|
||||||
class BaseArkApi:
|
class BaseArkApi:
|
||||||
proxy_url: str | None = proxy_url if proxy_url else None
|
proxy_url: str | None = proxy_url if proxy_url else None
|
||||||
_HEADER: ClassVar[dict[str, str]] = {
|
|
||||||
'Host': 'zonai.skland.com',
|
|
||||||
'platform': '1',
|
|
||||||
'Origin': 'https://www.skland.com',
|
|
||||||
'Referer': 'https://www.skland.com/',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'User-Agent': 'Skland/1.1.0 (com.hypergryph.skland; build:100100047; Android 33; ) Okhttp/4.11.0',
|
|
||||||
'vName': '1.1.0',
|
|
||||||
'vCode': '100100047',
|
|
||||||
}
|
|
||||||
|
|
||||||
async def _pass(self, gt: str, ch: str) -> tuple[str | None, str | None]:
|
async def _pass(self, gt: str, ch: str) -> tuple[str | None, str | None]:
|
||||||
_pass_api = core_plugins_config.get_config('_pass_API').data
|
_pass_api = core_plugins_config.get_config('_pass_API').data
|
||||||
@ -70,7 +72,7 @@ class BaseArkApi:
|
|||||||
if isinstance(is_vaild, bool):
|
if isinstance(is_vaild, bool):
|
||||||
await ArknightsUser.delete_user_data_by_uid(uid)
|
await ArknightsUser.delete_user_data_by_uid(uid)
|
||||||
return -61
|
return -61
|
||||||
header = deepcopy(self._HEADER)
|
header = deepcopy(_HEADER)
|
||||||
header['cred'] = cred
|
header['cred'] = cred
|
||||||
header = await self.set_sign(ARK_PLAYER_INFO, header=header)
|
header = await self.set_sign(ARK_PLAYER_INFO, header=header)
|
||||||
raw_data = await self.ark_request(
|
raw_data = await self.ark_request(
|
||||||
@ -94,7 +96,7 @@ class BaseArkApi:
|
|||||||
if isinstance(is_vaild, bool):
|
if isinstance(is_vaild, bool):
|
||||||
await ArknightsUser.delete_user_data_by_uid(uid)
|
await ArknightsUser.delete_user_data_by_uid(uid)
|
||||||
return -61
|
return -61
|
||||||
header = deepcopy(self._HEADER)
|
header = deepcopy(_HEADER)
|
||||||
header['cred'] = cred
|
header['cred'] = cred
|
||||||
header = await self.set_sign(ARK_SKD_SIGN, header=header)
|
header = await self.set_sign(ARK_SKD_SIGN, header=header)
|
||||||
raw_data = await self.ark_request(
|
raw_data = await self.ark_request(
|
||||||
@ -122,7 +124,7 @@ class BaseArkApi:
|
|||||||
if isinstance(is_vaild, bool):
|
if isinstance(is_vaild, bool):
|
||||||
await ArknightsUser.delete_user_data_by_uid(uid)
|
await ArknightsUser.delete_user_data_by_uid(uid)
|
||||||
return -61
|
return -61
|
||||||
header = deepcopy(self._HEADER)
|
header = deepcopy(_HEADER)
|
||||||
header['cred'] = cred
|
header['cred'] = cred
|
||||||
header = await self.set_sign(ARK_SKD_SIGN, header=header)
|
header = await self.set_sign(ARK_SKD_SIGN, header=header)
|
||||||
raw_data = await self.ark_request(
|
raw_data = await self.ark_request(
|
||||||
@ -142,8 +144,14 @@ class BaseArkApi:
|
|||||||
else:
|
else:
|
||||||
return msgspec.convert(unpack_data, ArknightsAttendanceCalendarModel)
|
return msgspec.convert(unpack_data, ArknightsAttendanceCalendarModel)
|
||||||
|
|
||||||
async def check_cred_valid(self, cred: str, token: str | None = None) -> bool | ArknightsUserMeModel:
|
async def check_cred_valid(
|
||||||
header = deepcopy(self._HEADER)
|
self, cred: str | None = None, token: str | None = None, uid: str | None = None
|
||||||
|
) -> bool | ArknightsUserMeModel:
|
||||||
|
if uid is not None:
|
||||||
|
cred = cred if cred else await ArknightsUser.get_user_attr_by_uid(uid=uid, attr='cred')
|
||||||
|
header = deepcopy(_HEADER)
|
||||||
|
if cred is None:
|
||||||
|
return False
|
||||||
header['cred'] = cred
|
header['cred'] = cred
|
||||||
header = await self.set_sign(ARK_USER_ME, header=header, token=token)
|
header = await self.set_sign(ARK_USER_ME, header=header, token=token)
|
||||||
raw_data = await self.ark_request(ARK_USER_ME, header=header)
|
raw_data = await self.ark_request(ARK_USER_ME, header=header)
|
||||||
@ -174,7 +182,7 @@ class BaseArkApi:
|
|||||||
return raw_data['data']
|
return raw_data['data']
|
||||||
|
|
||||||
async def refresh_token(self, cred: str, uid: str | None = None) -> str:
|
async def refresh_token(self, cred: str, uid: str | None = None) -> str:
|
||||||
header = deepcopy(self._HEADER)
|
header = deepcopy(_HEADER)
|
||||||
header['cred'] = cred
|
header['cred'] = cred
|
||||||
header['sign_enable'] = 'false'
|
header['sign_enable'] = 'false'
|
||||||
raw_data = await self.ark_request(url=ARK_REFRESH_TOKEN, header=header)
|
raw_data = await self.ark_request(url=ARK_REFRESH_TOKEN, header=header)
|
||||||
@ -215,6 +223,7 @@ class BaseArkApi:
|
|||||||
print(f'{path} {s2} {timestamp} {str1}')
|
print(f'{path} {s2} {timestamp} {str1}')
|
||||||
str2 = path + s2 + timestamp + str1
|
str2 = path + s2 + timestamp + str1
|
||||||
token_ = await ArknightsUser.get_token_by_cred(header['cred'])
|
token_ = await ArknightsUser.get_token_by_cred(header['cred'])
|
||||||
|
print(f'cred {header["cred"]} token {token} token_ {token_}')
|
||||||
token = token if token else token_
|
token = token if token else token_
|
||||||
if token is None:
|
if token is None:
|
||||||
raise Exception("token is None")
|
raise Exception("token is None")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user