`#绑定用户`的一些文案与逻辑调整

This commit is contained in:
Kokomi 2023-11-04 05:14:09 +08:00
parent e3d789fc91
commit b236fd40df
2 changed files with 20 additions and 10 deletions

View File

@ -54,11 +54,11 @@ export class user extends plugin {
fnc: 'checkCkStatus'
},
{
reg: '^#(接受)?绑定(主|子)?用户(\\[\\w+\\]){0,2}$',
reg: '^#(接受)?绑定(主|子)?(用户|账户|账号)(\\[\\w+\\]){0,2}$',
fnc: 'bindNoteUser'
},
{
reg: '^#(删除绑定|取消绑定|解除绑定|解绑|删除|取消)(主|子)用户$',
reg: '^#(删除绑定|取消绑定|解除绑定|解绑|删除|取消)(主|子)(用户|账户|账号)$',
fnc: 'bindNoteUser'
}
]

View File

@ -504,13 +504,13 @@ export default class User extends base {
let user = await this.user()
let id = user.qq
let { e } = this
let { msg } = e
let { msg, mainUserId, originalUserId } = e
if (!id) {
return true
}
if (/(删除绑定|取消绑定|解除绑定|解绑|删除|取消)/.test(msg)) {
// 删除用户
id = e.originalUserId || id
id = originalUserId || id
if (/主/.test(msg)) {
let mainId = await redis.get(`Yz:NoteUser:mainId:${id}`)
if (!mainId) {
@ -538,7 +538,7 @@ export default class User extends base {
}
return true
}
msg = msg.replace(/^#\s*(接受)?绑定(主|子)?用户/, '')
msg = msg.replace(/^#\s*(接受)?绑定(主|子)?(用户|账户|账号)/, '')
let idRet = /^\[(\w{5,})](?:\[(\w+)])?$/.exec(msg)
if (idRet && idRet[1]) {
let mainId = idRet[1]
@ -546,12 +546,16 @@ export default class User extends base {
if (!idRet[2]) {
// 子用户绑定
if (currId === mainId) {
if (originalUserId && originalUserId !== mainId && mainUserId === mainId) {
e.reply('当前账户已完成绑定...')
} else {
e.reply('请切换到需要绑定的子用户并发送绑定命令...')
}
return true
}
let verify = (Math.floor(100000000 + Math.random() * 100000000)).toString()
await redis.set(`Yz:NoteUser:verify:${mainId}`, verify + '||' + currId, { EX: 300 })
e.reply(['此账号即将作为子用户,绑定至主用户:${mainId}',
e.reply([`此账号将作为子用户,绑定至主用户:${mainId}`,
'成功绑定后此用户输入的命令将视作主用户命令使用主用户的CK与UID等信息',
'如需继续绑定请在5分钟内使用主账户发送以下命令', '',
`#接受绑定子用户[${mainId}][${verify}]`
@ -567,6 +571,7 @@ export default class User extends base {
verify = verify.split('||')
if (!verify || verify[0] !== idRet[2] || !verify[1]) {
e.reply('校验失败,请发送【#绑定用户】重新开始绑定流程')
await redis.del(`Yz:NoteUser:verify:${mainId}`)
return true
}
let subId = verify[1]
@ -579,9 +584,14 @@ export default class User extends base {
return true
}
} else {
this.e.reply(['将此账号作为主用户同Bot已绑定的子用户可使用主用户的CK及UID信息等信息。',
'可在多个QQ或频道间打通用户信息推荐使用QQ账户作为主用户。',
'请【切换至需要绑定的子用户】,输入以下命令,获得绑定验证码', '请勿接受不是自己用户的绑定!', '',
if (mainUserId && originalUserId && originalUserId !== mainUserId) {
e.reply('当前账户已有绑定的主账户,请使用主账户发起绑定...')
return true
}
e.reply(['将此账号作为【主用户】,绑定其他子用户。', '',
'可在多个QQ或频道间打通用户信息子用户会使用主用户的CK与UID等信息',
'注意:请勿接受不是自己用户的绑定!',
'请【切换至需要绑定的子用户】并发送以下命令,获得验证命令...', '',
`#绑定主用户[${id}]`].join('\n'))
}
}