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