mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
feat:默认设备信息绑定设备
This commit is contained in:
parent
d6a299c275
commit
dfe8419df8
2 changed files with 32 additions and 4 deletions
|
|
@ -107,6 +107,7 @@ export class User extends ZZZPlugin {
|
|||
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:BIND`);
|
||||
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:ID`);
|
||||
await redis.del(`ZZZ:DEVICE_FP:${uid}:FP`);
|
||||
await this.reply('解绑设备成功', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
async bindDeviceHelp() {
|
||||
|
|
|
|||
|
|
@ -157,11 +157,38 @@ export class ZZZPlugin extends plugin {
|
|||
body: sdk.body,
|
||||
});
|
||||
const fpRes = await res.json();
|
||||
logger.debug(`[米游社][设备指纹]${JSON.stringify(fpRes)}`);
|
||||
deviceFp = fpRes?.data?.device_fp;
|
||||
if (deviceFp) {
|
||||
await redis.set(`ZZZ:DEVICE_FP:${uid}:FP`, deviceFp, {
|
||||
EX: 86400 * 7,
|
||||
});
|
||||
if (!deviceFp) {
|
||||
return { api: null, uid: null, deviceFp: null };
|
||||
}
|
||||
await redis.set(`ZZZ:DEVICE_FP:${uid}:FP`, deviceFp, {
|
||||
EX: 86400 * 7,
|
||||
});
|
||||
if (!/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||
data['deviceFp'] = deviceFp;
|
||||
const deviceLogin = api.getUrl('deviceLogin', data);
|
||||
const saveDevice = api.getUrl('saveDevice', data);
|
||||
if (!!deviceLogin && !!saveDevice) {
|
||||
logger.debug(`[米游社][设备登录]保存设备信息`);
|
||||
try {
|
||||
logger.debug(`[米游社][设备登录]${JSON.stringify(deviceLogin)}`);
|
||||
const login = await request(deviceLogin.url, {
|
||||
headers: deviceLogin.headers,
|
||||
method: 'POST',
|
||||
body: deviceLogin.body,
|
||||
});
|
||||
const save = await request(saveDevice.url, {
|
||||
headers: saveDevice.headers,
|
||||
method: 'POST',
|
||||
body: saveDevice.body,
|
||||
});
|
||||
const result = await Promise.all([login.json(), save.json()]);
|
||||
logger.debug(`[米游社][设备登录]${JSON.stringify(result)}`);
|
||||
} catch (error) {
|
||||
logger.error(`[米游社][设备登录]${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue