🐛 修复可能出现的-10001 (#34)

* 修复可能出现的-10001

* 🚨 `pre-commit-ci`修复格式错误

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
RBAmeto 2023-10-18 20:25:33 +08:00 committed by GitHub
parent 97071e6965
commit 551ad5856f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,7 +207,7 @@ class BaseMysApi:
url=_URL, url=_URL,
method='GET', method='GET',
header=HEADER, header=HEADER,
params=params if params else {'server': server_id, 'role_id': uid}, params=params if params else {'role_id': uid, 'server': server_id},
use_proxy=True if is_os else False, use_proxy=True if is_os else False,
) )
return data return data
@ -265,6 +265,22 @@ class BaseMysApi:
for _ in range(2): for _ in range(2):
print(header) print(header)
if isinstance(params, Dict):
header['DS'] = get_ds_token(
'&'.join(
[
f'{k}={v}'
for k, v in sorted(
params.items(), key=lambda x: x[0]
)
]
)
)
if isinstance(data, Dict):
header['DS'] = get_ds_token(
'',
data,
)
async with client.request( async with client.request(
method, method,
url=url, url=url,
@ -307,13 +323,10 @@ class BaseMysApi:
) )
pass_header = copy.deepcopy(header) pass_header = copy.deepcopy(header)
ch = await self._upass(pass_header) ch = await self._upass(pass_header)
if ch == '':
return 114514
else:
header['x-rpc-challenge'] = ch header['x-rpc-challenge'] = ch
if isinstance(params, Dict):
header['DS'] = get_ds_token(
'&'.join(
[f'{k}={v}' for k, v in params.items()]
)
)
elif retcode != 0: elif retcode != 0:
return retcode return retcode
else: else:
@ -434,7 +447,7 @@ class MysApi(BaseMysApi):
async with client.request( async with client.request(
url=f'{_pass_api}&gt={gt}&challenge={ch}', url=f'{_pass_api}&gt={gt}&challenge={ch}',
method='GET', method='GET',
)as data: ) as data:
try: try:
data = await data.json() data = await data.json()
except ContentTypeError: except ContentTypeError:
@ -489,7 +502,9 @@ class MysApi(BaseMysApi):
header=header, header=header,
) )
async def get_header_and_vl(self, header: Dict, ch, vl, is_bbs: bool = False): async def get_header_and_vl(
self, header: Dict, ch, vl, is_bbs: bool = False
):
header['DS'] = get_ds_token( header['DS'] = get_ds_token(
'', '',
{ {
@ -499,7 +514,9 @@ class MysApi(BaseMysApi):
}, },
) )
_ = await self._mys_request( _ = await self._mys_request(
url=self.MAPI['VERIFY_URL'] if not is_bbs else self.MAPI['BBS_VERIFY_URL'], url=self.MAPI['VERIFY_URL']
if not is_bbs
else self.MAPI['BBS_VERIFY_URL'],
method='POST', method='POST',
header=header, header=header,
data={ data={