From 290a49b72490cddeae109e198c3313dc91e79d86 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 00:13:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=97=20=E6=96=B0=E5=A2=9E=E7=BE=A4?= =?UTF-8?q?=E7=AE=A1=E7=99=BD=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/groupAdmin/groupAdmin.js | 17 +++++++++++++++++ apps/groupAdmin/groupBannedWords.js | 4 +++- apps/groupAdmin/groupVerify.js | 1 + components/Config.js | 4 ++++ config/default_config/groupAdmin.yaml | 2 ++ 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 config/default_config/groupAdmin.yaml diff --git a/apps/groupAdmin/groupAdmin.js b/apps/groupAdmin/groupAdmin.js index 31f275b..53b6730 100644 --- a/apps/groupAdmin/groupAdmin.js +++ b/apps/groupAdmin/groupAdmin.js @@ -147,6 +147,10 @@ export class GroupAdmin extends plugin { { reg: '^#?(加|设|移)精$', fnc: 'essenceMessage' + }, + { + reg: '^#?群管(加|删)白(名单)?', + fnc: 'whiteQQ' } ] }) @@ -714,4 +718,17 @@ export class GroupAdmin extends plugin { } e.reply(res || `${isAdd}精失败`) } + + async whiteQQ () { + if (!common.checkPermission(this.e, 'master')) return + let type = /加/.test(this.e.msg) ? 'add' : 'del' + let qq = this.e.at || (this.e.msg.match(/\d+/)?.[0] || '') + + const isWhite = Config.groupAdmin.whiteQQ.includes(Number(qq)) + if (isWhite && type == 'add') return this.reply('❎ 此人已在群管白名单内') + if (!isWhite && type == 'del') return this.reply('❎ 此人未在群管白名单中') + + Config.modifyarr('groupAdmin', 'whiteQQ', qq, type) + this.reply(`✅ 已${type == 'add' ? '加入' : '删除'}${qq}到群管白名单`) + } } diff --git a/apps/groupAdmin/groupBannedWords.js b/apps/groupAdmin/groupBannedWords.js index ad419d8..8567d51 100644 --- a/apps/groupAdmin/groupBannedWords.js +++ b/apps/groupAdmin/groupBannedWords.js @@ -1,4 +1,5 @@ import { common, GroupBannedWords } from '../../model/index.js' +import { Config } from '../../components/index.js' import _ from 'lodash' export class NewGroupBannedWords extends plugin { @@ -47,7 +48,8 @@ export class NewGroupBannedWords extends plugin { } async monitor (e) { - if (!e.message || e.isMaster || e.member?.is_owner || e.member?.is_admin) { + const isWhite = Config.groupAdmin.whiteQQ.includes(e.user_id) + if (!e.message || e.isMaster || e.member?.is_owner || e.member?.is_admin || isWhite) { return false } const groupBannedWords = GroupBannedWords.initTextArr(e.group_id) diff --git a/apps/groupAdmin/groupVerify.js b/apps/groupAdmin/groupVerify.js index bb42b1e..621c756 100644 --- a/apps/groupAdmin/groupVerify.js +++ b/apps/groupAdmin/groupVerify.js @@ -137,6 +137,7 @@ Bot.on?.('notice.group.increase', async (e) => { if (!e.group.is_admin && !e.group.is_owner) return if (e.user_id == (e.bot ?? Bot).uin) return if (Config.masterQQ.includes(e.user_id)) return + if (Config.groupAdmin.whiteQQ.includes(e.user_id)) return await sleep(DelayTime * 1000) await verify(e.user_id, e.group_id, e) diff --git a/components/Config.js b/components/Config.js index 38dbb0d..45252b2 100644 --- a/components/Config.js +++ b/components/Config.js @@ -103,6 +103,10 @@ class Config { return this.getDefOrConfig('state') } + get groupAdmin () { + return this.getDefOrConfig('groupAdmin') + } + /** * 默认配置和用户配置 * @param name diff --git a/config/default_config/groupAdmin.yaml b/config/default_config/groupAdmin.yaml new file mode 100644 index 0000000..9547f82 --- /dev/null +++ b/config/default_config/groupAdmin.yaml @@ -0,0 +1,2 @@ +#白名单QQ +whiteQQ: [10086 , 114514] \ No newline at end of file