From ade970b89167ca4c4e3d4de6822ffcf72acbd008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=89=E9=A3=8E=E6=9D=A5?= <3139373986@qq.com> Date: Wed, 3 Apr 2024 06:12:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=97=20=E6=96=B0=E5=A2=9E=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95=E8=A2=AB=E7=A6=81=E8=A8=80=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=A7=A3=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/events/notice_group.js | 17 ++++++++++++++++- apps/groupAdmin/groupAdmin.js | 16 ++++++++++++++++ config/default_config/groupAdmin.yaml | 4 +++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/apps/events/notice_group.js b/apps/events/notice_group.js index fff1711..ed0628b 100644 --- a/apps/events/notice_group.js +++ b/apps/events/notice_group.js @@ -141,9 +141,24 @@ Bot.on?.('notice.group', async (e) => { } break } - // 禁言 (这里仅处理机器人被禁言) + // 禁言 case 'ban': { const forbiddenTime = formatDuration(e.duration, 'default') + /** 处理白名单禁言 */ + const { groupAdmin } = Config + const isMaster = Config.masterQQ?.includes(e.operator_id) || e.operator_id === (e.bot ?? Bot).uin + const isWhiteUser = groupAdmin.whiteQQ.includes(e.user_id) + + if ( + isWhiteUser && + !isMaster && + groupAdmin.noBan && + (e.group.is_admin || e.group.is_owner) && + e.duration !== 0 + ) { + await e.group.muteMember(e.user_id, 0) + e.reply('已解除白名单用户的禁言') + } if (!Config.getGroup(e.group_id).botBeenBanned) return false diff --git a/apps/groupAdmin/groupAdmin.js b/apps/groupAdmin/groupAdmin.js index afc3237..a23df00 100644 --- a/apps/groupAdmin/groupAdmin.js +++ b/apps/groupAdmin/groupAdmin.js @@ -151,6 +151,10 @@ export class GroupAdmin extends plugin { { reg: '^#?群管(加|删)白(名单)?', fnc: 'whiteQQ' + }, + { + reg: '^#?(开启|关闭)白名单(自动)?解禁', + fnc: 'noBan' } ] }) @@ -731,4 +735,16 @@ export class GroupAdmin extends plugin { Config.modifyarr('groupAdmin', 'whiteQQ', qq, type) this.reply(`✅ 已${type == 'add' ? '加入' : '删除'}${qq}到群管白名单`) } + + async noBan () { + if (!common.checkPermission(this.e, 'master')) return + let type = !!/开启/.test(this.e.msg) + + const { noBan } = Config.groupAdmin + if (noBan && type) return this.reply('❎ 白名单自动解禁已处于开启状态') + if (!noBan && !type) return this.reply('❎ 白名单自动解禁已处于关闭状态') + + Config.modify('groupAdmin', 'noBan', type) + this.reply(`✅ 已${type ? '开启' : '关闭'}白名单自动解禁`) + } } diff --git a/config/default_config/groupAdmin.yaml b/config/default_config/groupAdmin.yaml index 9547f82..c62d5d2 100644 --- a/config/default_config/groupAdmin.yaml +++ b/config/default_config/groupAdmin.yaml @@ -1,2 +1,4 @@ #白名单QQ -whiteQQ: [10086 , 114514] \ No newline at end of file +whiteQQ: [] +#白名单禁言自动解禁 +noBan: false \ No newline at end of file