From 2932fc6dfd01170fc5f8a51314fd80124efa1c0a Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Wed, 7 Jun 2023 23:23:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore(banlist-template.py):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/templates/banlist-template.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/res/templates/banlist-template.py b/res/templates/banlist-template.py index 4b4d240..dcaf375 100644 --- a/res/templates/banlist-template.py +++ b/res/templates/banlist-template.py @@ -1,3 +1,13 @@ +# 是否处理群聊消息 +# 为False时忽略所有群聊消息 +# 优先级高于下方禁用列表 +enable_group = True + +# 是否处理私聊消息 +# 为False时忽略所有私聊消息 +# 优先级高于下方禁用列表 +enable_private = True + # 是否启用禁用列表 enable = True From 782c0e22eac92a5e7d4024c63f6a9ff6bd64a5b2 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Wed, 7 Jun 2023 23:47:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=85=A8=E5=B1=80=E7=BE=A4=E8=81=8A=E3=80=81=E7=A7=81?= =?UTF-8?q?=E8=81=8A=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/qqbot/manager.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/qqbot/manager.py b/pkg/qqbot/manager.py index be8c306..dd0f609 100644 --- a/pkg/qqbot/manager.py +++ b/pkg/qqbot/manager.py @@ -102,6 +102,9 @@ class QQBotManager: enable_banlist = False + enable_private = True + enable_group = True + ban_person = [] ban_group = [] @@ -242,6 +245,11 @@ class QQBotManager: self.ban_group = banlist.group logging.info("加载禁用列表: person: {}, group: {}".format(self.ban_person, self.ban_group)) + if hasattr(banlist, "enable_private"): + self.enable_private = banlist.enable_private + if hasattr(banlist, "enable_group"): + self.enable_group = banlist.enable_group + config = pkg.utils.context.get_config() if os.path.exists("sensitive.json") \ and config.sensitive_word_filter is not None \ @@ -269,7 +277,9 @@ class QQBotManager: import config reply = '' - if event.sender.id == self.bot_account_id: + if not self.enable_private: + logging.debug("已在banlist.py中禁用所有私聊") + elif event.sender.id == self.bot_account_id: pass else: if Image in event.message_chain: @@ -342,8 +352,10 @@ class QQBotManager: replys = [tips_custom.replys_message] return replys - - if Image in event.message_chain: + + if not self.enable_group: + logging.debug("已在banlist.py中禁用所有群聊") + elif Image in event.message_chain: pass else: if At(self.bot_account_id) in event.message_chain and response_at(event.group.id): From 497a393e831ad9617bdec3af20487ef744a61715 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Wed, 7 Jun 2023 23:49:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?doc:=20=E4=BF=AE=E6=94=B9wiki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/wiki/功能使用.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/wiki/功能使用.md b/res/wiki/功能使用.md index aee88fc..df469bc 100644 --- a/res/wiki/功能使用.md +++ b/res/wiki/功能使用.md @@ -375,4 +375,5 @@ prompt_submit_length = <模型单次请求token数上限> - 情景预设中token ### 加入黑名单 -编辑`banlist.py`,设置`enable = True`,并在其中的`person`或`group`列表中加入要封禁的人或群聊,修改完成后重启程序或进行热重载 \ No newline at end of file +- 支持禁用所有`私聊`或`群聊`,请查看`banlist.py`中的`enable_private`和`enable_group`字段 +- 编辑`banlist.py`,设置`enable = True`,并在其中的`person`或`group`列表中加入要封禁的人或群聊,修改完成后重启程序或进行热重载 \ No newline at end of file