mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
移除apps插件非必要return false,拦截指令向后传递 #138
This commit is contained in:
parent
3273f256fc
commit
9d676fa70a
17 changed files with 82 additions and 173 deletions
30
apps/user.js
30
apps/user.js
|
|
@ -30,8 +30,7 @@ export class User extends ZZZPlugin {
|
|||
async bindDevice() {
|
||||
const uid = await this.getUID();
|
||||
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||
await this.reply('国际服不需要绑定设备');
|
||||
return false;
|
||||
return this.reply('国际服不需要绑定设备');
|
||||
}
|
||||
//先throw一步(
|
||||
this.setContext('toBindDevice');
|
||||
|
|
@ -44,32 +43,27 @@ export class User extends ZZZPlugin {
|
|||
async toBindDevice() {
|
||||
const ltuid = await this.getLtuid();
|
||||
if (!ltuid) {
|
||||
this.reply('未绑定UID');
|
||||
this.finish('toBindDevice');
|
||||
return false;
|
||||
return this.reply('未绑定UID');
|
||||
}
|
||||
const msg = this.e.msg.trim();
|
||||
if (!msg) {
|
||||
this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
return this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
if (msg.includes('取消')) {
|
||||
await this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||
this.finish('toBindDevice');
|
||||
return false;
|
||||
return this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
try {
|
||||
const info = JSON.parse(msg);
|
||||
if (!info) {
|
||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
if (!!info?.device_id && !!info.device_fp) {
|
||||
this.finish('toBindDevice');
|
||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, info.device_fp);
|
||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:ID`, info.device_id);
|
||||
await this.reply('绑定设备成功', false, { at: true, recallMsg: 100 });
|
||||
this.finish('toBindDevice');
|
||||
return false;
|
||||
return this.reply('绑定设备成功', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
if (
|
||||
!info?.deviceName ||
|
||||
|
|
@ -80,24 +74,20 @@ export class User extends ZZZPlugin {
|
|||
!info?.deviceFingerprint ||
|
||||
!info?.deviceProduct
|
||||
) {
|
||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:BIND`, JSON.stringify(info));
|
||||
const { deviceFp } = await this.getAPI();
|
||||
if (!deviceFp) {
|
||||
await this.reply('绑定设备失败');
|
||||
return false;
|
||||
return this.reply('绑定设备失败');
|
||||
}
|
||||
logger.debug(`[LTUID:${ltuid}]绑定设备成功,deviceFp:${deviceFp}`);
|
||||
await this.reply(`绑定设备成功${this.e.isGroup ? '\n请撤回设备信息' : ''}`, false, { at: true, recallMsg: 100 });
|
||||
} catch (error) {
|
||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
} finally {
|
||||
this.finish('toBindDevice');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async deleteBind() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue