mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
加入缓存机制,避免重复请求导致刷屏
This commit is contained in:
parent
c69d8fe6f8
commit
41ce7b08c4
@ -66,6 +66,12 @@ export async function gclog(e) {
|
||||
e.reply("请先绑定stoken")
|
||||
return true;
|
||||
}
|
||||
let redis_Data = await redis.get(`xiaoyao:gclog:${e.user_id}`);
|
||||
if(redis_Data){
|
||||
let time=redis_Data*1-Math.floor(Date.now()/1000);
|
||||
e.reply(`请求过快,请${time}秒后重试...`);
|
||||
return true;
|
||||
}
|
||||
let miHoYoApi = new MihoYoApi(e);
|
||||
let kkbody = await miHoYoApi.getbody("原神");
|
||||
const objData = await miHoYoApi.getUserInfo(kkbody)
|
||||
@ -110,5 +116,8 @@ export async function gclog(e) {
|
||||
e.isPrivate = true;
|
||||
await bing(e)
|
||||
}
|
||||
redis.set(`xiaoyao:gclog:${e.user_id}`, Math.floor(Date.now()/1000)+(60*5), { //把色图链接写入缓存防止一直色色
|
||||
EX: 60*5
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user