check cred valid

This commit is contained in:
qwerdvd 2023-08-18 20:33:21 +08:00
parent b240d56c6f
commit d6272061f5
2 changed files with 8 additions and 13 deletions

View File

@ -1,13 +0,0 @@
from pathlib import Path
from PIL import Image
path = Path(__file__).parent / 'texture2D'
char = Image.open(path / 'char_1028_texas2_1b.png')
mask = Image.open(path / 'mask.png')
img = Image.new('RGB',(850,1750))
temp_img = Image.new('RGB',(850,1750))
temp_img.paste(char, (-500,0), char )
img.paste(temp_img, (0,0), mask)
img.show()

View File

@ -25,6 +25,10 @@ class BaseArkApi:
cred = await ArknightsUser.get_user_attr_by_uid(uid=uid, attr='cred') cred = await ArknightsUser.get_user_attr_by_uid(uid=uid, attr='cred')
if cred is None: if cred is None:
return -61 return -61
is_vaild = await self.check_cred_valid(cred)
if isinstance(is_vaild, bool):
await ArknightsUser.delete_user_data_by_uid(uid)
return -61
header = deepcopy(self._HEADER) header = deepcopy(self._HEADER)
header['Cred'] = cred header['Cred'] = cred
raw_data = await self._ark_request( raw_data = await self._ark_request(
@ -79,6 +83,7 @@ class BaseArkApi:
arkUser = await ArknightsUser.base_select_data(Cred=Cred) arkUser = await ArknightsUser.base_select_data(Cred=Cred)
if arkUser is None: if arkUser is None:
return -61 return -61
print(Cred)
header['Cred'] = Cred header['Cred'] = Cred
async with ClientSession( async with ClientSession(
@ -94,6 +99,9 @@ class BaseArkApi:
) as resp: ) as resp:
try: try:
raw_data = await resp.json() raw_data = await resp.json()
with open('test.json', 'w', encoding='utf-8') as f:
import json
json.dump(raw_data, f, ensure_ascii=False, indent=4)
except ContentTypeError: except ContentTypeError:
_raw_data = await resp.text() _raw_data = await resp.text()
raw_data = {'code': -999, 'data': _raw_data} raw_data = {'code': -999, 'data': _raw_data}