mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🎨 完善绑定流程, 修复刷新ck
This commit is contained in:
parent
44cae95745
commit
548fc8a2a5
@ -78,6 +78,6 @@ async def send_add_device_msg(bot: Bot, ev: Event):
|
|||||||
for user in user_list:
|
for user in user_list:
|
||||||
if user.cookie:
|
if user.cookie:
|
||||||
await mys_api.device_login_and_save(
|
await mys_api.device_login_and_save(
|
||||||
device_id, fp, data['deviceModel'], user.cookie
|
device_id, fp, data['deviceFingerprint'], user.cookie
|
||||||
)
|
)
|
||||||
await bot.send('设备绑定成功!')
|
await bot.send('设备绑定成功!')
|
||||||
|
@ -215,12 +215,14 @@ class BaseMysApi:
|
|||||||
return res["data"]["device_fp"]
|
return res["data"]["device_fp"]
|
||||||
|
|
||||||
async def device_login_and_save(
|
async def device_login_and_save(
|
||||||
self, device_id: str, device_fp: str, model_name: str, cookie: str
|
self, device_id: str, device_fp: str, device_info: str, cookie: str
|
||||||
):
|
):
|
||||||
|
info = device_info.split('/')
|
||||||
|
brand, model_name = info[0], info[1]
|
||||||
body = {
|
body = {
|
||||||
"app_version": self.mysVersion,
|
"app_version": self.mysVersion,
|
||||||
"device_id": device_id,
|
"device_id": device_id,
|
||||||
"device_name": f"{model_name}",
|
"device_name": f"{brand}{model_name}",
|
||||||
"os_version": "33",
|
"os_version": "33",
|
||||||
"platform": "Android",
|
"platform": "Android",
|
||||||
"registration_id": self.generate_seed(19),
|
"registration_id": self.generate_seed(19),
|
||||||
@ -229,10 +231,13 @@ class BaseMysApi:
|
|||||||
HEADER = copy.deepcopy(self._HEADER)
|
HEADER = copy.deepcopy(self._HEADER)
|
||||||
HEADER['x-rpc-device_id'] = device_id
|
HEADER['x-rpc-device_id'] = device_id
|
||||||
HEADER['x-rpc-device_fp'] = device_fp
|
HEADER['x-rpc-device_fp'] = device_fp
|
||||||
HEADER['x-rpc-device_name'] = f"{model_name}"
|
HEADER['x-rpc-device_name'] = f"{brand} {model_name}"
|
||||||
HEADER['x-rpc-device_model'] = model_name
|
HEADER['x-rpc-device_model'] = model_name
|
||||||
|
HEADER['x-rpc-csm_source'] = 'myself'
|
||||||
|
HEADER['Referer'] = 'https://app.mihoyo.com'
|
||||||
|
HEADER['Host'] = 'bbs-api.miyoushe.com'
|
||||||
HEADER['DS'] = generate_passport_ds('', body)
|
HEADER['DS'] = generate_passport_ds('', body)
|
||||||
HEADER['cookie'] = cookie
|
HEADER['Cookie'] = cookie
|
||||||
|
|
||||||
await self._mys_request(
|
await self._mys_request(
|
||||||
url=self.MAPI['DEVICE_LOGIN'],
|
url=self.MAPI['DEVICE_LOGIN'],
|
||||||
@ -341,15 +346,22 @@ class BaseMysApi:
|
|||||||
async def ck_in_new_device(
|
async def ck_in_new_device(
|
||||||
self, uid: str, app_cookie: Optional[str] = None
|
self, uid: str, app_cookie: Optional[str] = None
|
||||||
):
|
):
|
||||||
|
data = await GsUser.base_select_data(stoken=app_cookie)
|
||||||
device_id = self.get_device_id()
|
device_id = self.get_device_id()
|
||||||
seed_id, seed_time = self.get_seed()
|
seed_id, seed_time = self.get_seed()
|
||||||
model_name = self.generate_model_name()
|
if data and data.device_info:
|
||||||
fp = await self.generate_fake_fp(device_id, seed_id, seed_time)
|
fp = data.fp
|
||||||
|
device_info = data.device_info
|
||||||
|
else:
|
||||||
|
fp = await self.generate_fake_fp(device_id, seed_id, seed_time)
|
||||||
|
device_info = 'OnePlus/PHK110/OP2020L1'
|
||||||
if app_cookie is None:
|
if app_cookie is None:
|
||||||
app_cookie = await self.get_stoken(uid)
|
app_cookie = await self.get_stoken(uid)
|
||||||
if app_cookie is None:
|
if app_cookie is None:
|
||||||
return logger.warning('设备登录流程错误...')
|
return logger.warning('设备登录流程错误...')
|
||||||
await self.device_login_and_save(device_id, fp, model_name, app_cookie)
|
await self.device_login_and_save(
|
||||||
|
device_id, fp, device_info, app_cookie
|
||||||
|
)
|
||||||
if await GsUser.user_exists(uid, 'sr' if self.is_sr else None):
|
if await GsUser.user_exists(uid, 'sr' if self.is_sr else None):
|
||||||
await GsUser.update_data_by_uid_without_bot_id(
|
await GsUser.update_data_by_uid_without_bot_id(
|
||||||
uid, 'sr' if self.is_sr else None, fp=fp, device_id=device_id
|
uid, 'sr' if self.is_sr else None, fp=fp, device_id=device_id
|
||||||
|
@ -57,6 +57,8 @@ async def refresh_ck_by_uid_list(bot_id: str, uid_dict: Dict):
|
|||||||
error_num = 0
|
error_num = 0
|
||||||
for uid in uid_dict:
|
for uid in uid_dict:
|
||||||
stoken = await GsUser.get_user_stoken_by_uid(uid)
|
stoken = await GsUser.get_user_stoken_by_uid(uid)
|
||||||
|
# account_id = await GsUser.get_user_attr_by_uid(uid, 'mys_id')
|
||||||
|
# _stoken = f'{stoken};account_id={account_id}'
|
||||||
if stoken is None:
|
if stoken is None:
|
||||||
skip_num += 1
|
skip_num += 1
|
||||||
error_num += 1
|
error_num += 1
|
||||||
@ -264,7 +266,6 @@ async def _deal_ck(bot_id: str, mes: str, user_id: str) -> str:
|
|||||||
wd_uid=wd_uid_bind,
|
wd_uid=wd_uid_bind,
|
||||||
fp=nd[0],
|
fp=nd[0],
|
||||||
device_id=nd[1],
|
device_id=nd[1],
|
||||||
OAID=None,
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await GsUser.insert_data(
|
await GsUser.insert_data(
|
||||||
@ -291,7 +292,6 @@ async def _deal_ck(bot_id: str, mes: str, user_id: str) -> str:
|
|||||||
device_id=nd[1],
|
device_id=nd[1],
|
||||||
sr_push_switch='off',
|
sr_push_switch='off',
|
||||||
sr_sign_switch='off',
|
sr_sign_switch='off',
|
||||||
OAID=None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
im_list.append(
|
im_list.append(
|
||||||
|
@ -107,7 +107,7 @@ class BaseIDModel(SQLModel):
|
|||||||
🌱参数:
|
🌱参数:
|
||||||
|
|
||||||
🔹`**data`
|
🔹`**data`
|
||||||
插入的数据, 入参列名等于数据即可
|
选择的数据, 入参列名等于数据即可
|
||||||
|
|
||||||
🚀使用范例:
|
🚀使用范例:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user