From 17406bd8dbbdca67792fc70159af0ffd56ac90f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Sun, 4 Jun 2023 12:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=20Miao-Yunzai=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/loader.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index ec58f6a..14a461e 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -62,6 +62,8 @@ class PluginsLoader { /** 插件监听 */ this.watcher = {} + this.msgThrottle = {} + /** 星铁命令前缀 */ this.srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/ } @@ -657,6 +659,17 @@ class PluginsLoader { return false } + let { msgThrottle } = this + + let msgId = e.user_id + ':' + e.raw_message + if (msgThrottle[msgId]) { + return false + } + msgThrottle[msgId] = true + setTimeout(() => { + delete msgThrottle[msgId] + }, 200) + return true }