2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 11:40:51 +08:00

修正V3体力渲染异常问题

This commit is contained in:
ctrlcvs 2022-08-06 23:39:06 +08:00
parent 5b719abeba
commit c496c4bc8b

View File

@ -10,6 +10,8 @@ let bingCkUid = {}
let bingCkQQ = {} let bingCkQQ = {}
let bingCkLtuid = {} let bingCkLtuid = {}
let tmpCk = {}
export default class MysInfo { export default class MysInfo {
/** redis key */ /** redis key */
static keyPre = 'Yz:genshin:mys:' static keyPre = 'Yz:genshin:mys:'
@ -61,13 +63,16 @@ export default class MysInfo {
if (mysInfo.checkAuth(api)) { if (mysInfo.checkAuth(api)) {
/** 获取ck绑定uid */ /** 获取ck绑定uid */
mysInfo.uid = (await MysInfo.getSelfUid(e)).uid mysInfo.uid = (await MysInfo.getSelfUid(e))
} else { } else {
/** 获取uid */ /** 获取uid */
mysInfo.uid = await MysInfo.getUid(e) mysInfo.uid = await MysInfo.getUid(e)
} }
if (!mysInfo.uid) return false if (!mysInfo.uid) {
e.noTips = true
return false
}
mysInfo.e.uid = mysInfo.uid mysInfo.e.uid = mysInfo.uid
@ -82,7 +87,11 @@ export default class MysInfo {
/** 获取uid */ /** 获取uid */
static async getUid (e) { static async getUid (e) {
if (e.uid) return e.uid if (e.uid) {
/** 没有绑定的自动绑定 */
MysInfo.uidBingQQ(e, e.uid)
return String(e.uid)
}
let { msg = '', at = '' } = e let { msg = '', at = '' } = e
@ -93,7 +102,7 @@ export default class MysInfo {
if (at) { if (at) {
uid = await redis.get(`${MysInfo.key.qqUid}${at}`) uid = await redis.get(`${MysInfo.key.qqUid}${at}`)
if (uid) return String(uid) if (uid) return String(uid)
e.reply('尚未绑定uid', false, { at }) if (e.noTips !== true) e.reply('尚未绑定uid', false, { at })
return false return false
} }
@ -105,7 +114,11 @@ export default class MysInfo {
/** 命令消息携带 */ /** 命令消息携带 */
uid = matchUid(msg) uid = matchUid(msg)
if (uid) return String(uid) if (uid) {
/** 没有绑定的自动绑定 */
MysInfo.uidBingQQ(e, uid)
return String(uid)
}
/** 绑定的uid */ /** 绑定的uid */
uid = await redis.get(`${MysInfo.key.qqUid}${e.user_id}`) uid = await redis.get(`${MysInfo.key.qqUid}${e.user_id}`)
@ -115,14 +128,14 @@ export default class MysInfo {
uid = matchUid(e.sender.card) uid = matchUid(e.sender.card)
if (uid) return String(uid) if (uid) return String(uid)
e.reply('请先#绑定uid', false, { at }) if (e.noTips !== true) e.reply('请先#绑定uid', false, { at })
return false return false
} }
/** 获取ck绑定uid */ /** 获取ck绑定uid */
static async getSelfUid (e) { static async getSelfUid (e) {
if (e.uid) return e.uid // if (e.uid) return e.uid
let { msg = '', at = '' } = e let { msg = '', at = '' } = e
@ -130,16 +143,26 @@ export default class MysInfo {
/** at用户 */ /** at用户 */
if (at && (!bingCkQQ[at] || !bingCkQQ[at].uid)) { if (at && (!bingCkQQ[at] || !bingCkQQ[at].uid)) {
e.reply('尚未绑定cookie', false, { at }) if (e.noTips !== true) e.reply('尚未绑定cookie', false, { at })
return false return false
} }
if (!e.user_id || !bingCkQQ[e.user_id] || !bingCkQQ[e.user_id].uid) { if (!e.user_id || !bingCkQQ[e.user_id] || !bingCkQQ[e.user_id].uid) {
e.reply(MysInfo.tips, false, { at }) if (e.noTips !== true) e.reply(MysInfo.tips, false, { at })
return false return false
} }
return bingCkQQ[e.user_id] /** 当前查询uid不是绑定的uid */
if (e.uid && e.uid != bingCkQQ[e.user_id].uid) return false
return bingCkQQ[e.user_id].uid
}
/** 没有绑定的自动绑定 */
static async uidBingQQ (e, uid) {
if (!await redis.get(`${MysInfo.key.qqUid}${e.user_id}`)) {
await redis.setEx(`${MysInfo.key.qqUid}${e.user_id}`, 3600 * 24 * 30, String(uid))
}
} }
/** 判断绑定ck才能查询 */ /** 判断绑定ck才能查询 */
@ -214,6 +237,10 @@ export default class MysInfo {
} }
async getCookie () { async getCookie () {
if (tmpCk[this.uid]) {
this.ckInfo = tmpCk[this.uid]
return this.ckInfo.ck
}
if (this.ckInfo.ck) return this.ckInfo.ck if (this.ckInfo.ck) return this.ckInfo.ck
// 使用用户uid绑定的ck // 使用用户uid绑定的ck
await this.getBingCK() || await this.getBingCK() ||
@ -224,6 +251,12 @@ export default class MysInfo {
// 使用公共ck // 使用公共ck
await this.getPublicCK() await this.getPublicCK()
tmpCk[this.uid] = this.ckInfo
setTimeout(() => {
delete tmpCk[this.uid]
}, 1000 * 30)
return this.ckInfo.ck return this.ckInfo.ck
} }