mirror of
https://github.com/baiqwerdvd/ArknightsUID.git
synced 2025-05-05 03:23:45 +08:00
🚨修复绑定错误
This commit is contained in:
parent
bc4c1983ec
commit
bad6bcdd76
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from gsuid_core.utils.plugins_config.models import (
|
from gsuid_core.utils.plugins_config.models import (
|
||||||
GSC,
|
GSC,
|
||||||
GsStrConfig,
|
GsStrConfig,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from ..utils.ark_api import ark_skd_api
|
from ..utils.ark_api import ark_skd_api
|
||||||
from ..utils.database.models import ArknightsUser
|
from ..utils.database.models import ArknightsUser
|
||||||
|
|
||||||
ERROR_HINT = '添加失败,格式为:用户ID - Cred\n \
|
ERROR_HINT = '添加失败,格式为:明日方舟UID - Cred\n \
|
||||||
例如:1810461245 - VropL583Sb1hClS5buQ4nSASkDlL8tMT'
|
例如:1810461245 - VropL583Sb1hClS5buQ4nSASkDlL8tMT'
|
||||||
|
|
||||||
|
|
||||||
@ -11,11 +11,16 @@ async def deal_skd_cred(bot_id: str, cred: str, user_id: str) -> str:
|
|||||||
_ck = cred.replace(' ', '').split('-')
|
_ck = cred.replace(' ', '').split('-')
|
||||||
if len(_ck) != 2 or not _ck[0] or not _ck[0].isdigit() or not _ck[1]:
|
if len(_ck) != 2 or not _ck[0] or not _ck[0].isdigit() or not _ck[1]:
|
||||||
return ERROR_HINT
|
return ERROR_HINT
|
||||||
|
print(_ck)
|
||||||
|
print(_ck[0], _ck[1])
|
||||||
|
|
||||||
check_cred = await ark_skd_api.check_cred_valid(_ck[1])
|
check_cred = await ark_skd_api.check_cred_valid(_ck[1])
|
||||||
if check_cred:
|
print(check_cred)
|
||||||
|
if isinstance(check_cred, bool):
|
||||||
return 'Cred无效!'
|
return 'Cred无效!'
|
||||||
|
else:
|
||||||
|
skd_uid = check_cred.user.id_
|
||||||
uid, cred = _ck[0], _ck[1]
|
uid, cred = _ck[0], _ck[1]
|
||||||
await ArknightsUser.insert_data(user_id, bot_id,
|
await ArknightsUser.insert_data(user_id, bot_id,
|
||||||
Cred=cred, uid=uid, skd_uid=check_cred)
|
cred=cred, uid=uid, skd_uid=skd_uid)
|
||||||
return '添加成功!'
|
return '添加成功!'
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Any, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
|
import msgspec
|
||||||
from aiohttp import ClientSession, ContentTypeError, TCPConnector
|
from aiohttp import ClientSession, ContentTypeError, TCPConnector
|
||||||
from gsuid_core.logger import logger
|
from gsuid_core.logger import logger
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ class BaseArkApi:
|
|||||||
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
|
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
|
||||||
}
|
}
|
||||||
|
|
||||||
async def check_cred_valid(self, Cred: str) -> bool | str:
|
async def check_cred_valid(self, Cred: str) -> bool | ArknightsUserMeModel:
|
||||||
header = deepcopy(self._HEADER)
|
header = deepcopy(self._HEADER)
|
||||||
header['Cred'] = Cred
|
header['Cred'] = Cred
|
||||||
raw_data = await self._ark_request(ARK_USER_ME, header=header)
|
raw_data = await self._ark_request(ARK_USER_ME, header=header)
|
||||||
@ -28,7 +29,7 @@ class BaseArkApi:
|
|||||||
if isinstance(unpack_data, int):
|
if isinstance(unpack_data, int):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return ArknightsUserMeModel(**unpack_data).user.id_
|
return msgspec.convert(unpack_data, type=ArknightsUserMeModel)
|
||||||
|
|
||||||
def unpack(self, raw_data: dict | int) -> dict | int:
|
def unpack(self, raw_data: dict | int) -> dict | int:
|
||||||
if isinstance(raw_data, dict):
|
if isinstance(raw_data, dict):
|
||||||
|
@ -78,7 +78,7 @@ class UserMeInfo(Struct):
|
|||||||
birthday: str
|
birthday: str
|
||||||
|
|
||||||
|
|
||||||
class ArknightsUserMeModel(Struct):
|
class ArknightsUserMeModel(Struct, omit_defaults=True):
|
||||||
user: UserMeInfo
|
user: UserMeInfo
|
||||||
userRts: UserMeInfoRts
|
userRts: UserMeInfoRts
|
||||||
userSanctionList: list[str]
|
userSanctionList: list[str]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user