#17 h2o
// 检查用户请求限制
if (!config.userRequests[username]) {
config.userRequests[username] = { count: 0, lastClaim: 0 };
}
if (currentTime - config.userRequests[username].lastClaim < hourInMillis) {
if (config.userRequests[username].count >= 1) {
return res.status(429).send('你最近已经领取过了');
}
} else {
config.userRequests[username].count = 0; // Reset count after an hour
}
// 检查 IP 请求限制
if (!config.ipRequests[ip]) {
config.ipRequests[ip] = { count: 0, lastClaim: 0 };
}
if (currentTime - config.ipRequests[ip].lastClaim < hourInMillis) {
if (config.ipRequests[ip].count >= 1) {
return res.status(429).send('你最近已经领取过了');
}
} else {
config.ipRequests[ip].count = 0; // Reset count after an hour
}