Merge pull request #56 from SmallK111407/main

调整 %更新抽卡记录 的判断顺序,防止出现未绑定cookie时进行更新出现的无效CD
This commit is contained in:
bietiaop 2024-08-19 23:33:17 +08:00 committed by GitHub
commit abb932868b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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);