mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 perf: 简化限流算法 & ✨ feat: 增强哔哩哔哩解析健壮性,防止高并发环境下解析致使服务器宕机
This commit is contained in:
parent
f1e21accbe
commit
1148d24ef5
@ -327,8 +327,8 @@ export class tools extends plugin {
|
|||||||
|
|
||||||
// bilibi解析
|
// bilibi解析
|
||||||
async bili(e) {
|
async bili(e) {
|
||||||
await this.limitUserUse(e, async () => {
|
await this.limitUserUse(e, () => {
|
||||||
await this.biliCore(e);
|
this.biliCore(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async biliCore(e) {
|
async biliCore(e) {
|
||||||
@ -1217,7 +1217,7 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 限制用户调用(默认1分钟1次)
|
* 限制用户调用
|
||||||
* @param e
|
* @param e
|
||||||
* @param func
|
* @param func
|
||||||
* @return {Promise<void>}
|
* @return {Promise<void>}
|
||||||
@ -1226,7 +1226,7 @@ export class tools extends plugin {
|
|||||||
if (tools.#tokenBucket.consume(e.user_id, 1)) {
|
if (tools.#tokenBucket.consume(e.user_id, 1)) {
|
||||||
await func();
|
await func();
|
||||||
} else {
|
} else {
|
||||||
logger.warn(`解析被限制使用`, true);
|
logger.warn(`解析被限制使用`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user