调整 %更新抽卡记录 的判断顺序,防止出现未绑定cookie时进行更新出现的无效CD

This commit is contained in:
SmallK111407 2024-08-19 23:29:58 +08:00
parent 2602647d1b
commit 7ab38101e2

View file

@ -135,17 +135,17 @@ export class GachaLog extends ZZZPlugin {
const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`);
const gachaConfig = settings.getConfig('gacha');
const coldTime = _.get(gachaConfig, 'interval', 300);
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
return false;
}
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
try {
const key = await getAuthKey(this.e, this.User, uid);
if (!key) {
await this.reply('authKey获取失败请检查cookie是否过期');
return false;
}
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
return false;
}
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
this.getLog(key);
} catch (error) {
await this.reply(error.message);