From 4d8790655941f7d057653e791ba451fbb348b0eb Mon Sep 17 00:00:00 2001 From: erayyym Date: Tue, 5 Dec 2023 13:18:42 -0500 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 本地跑没有问题,用户打开这个功能需要在config.json加入 "group_chat_exit_group": true, (但是不确定写的对不对,刚开始学cs哈哈,之前没搞过这个) --- config.py | 1 + plugins/hello/hello.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 6cc5708..550c4f3 100644 --- a/config.py +++ b/config.py @@ -40,6 +40,7 @@ available_setting = { "image_create_prefix": ["画", "看", "找"], # 开启图片回复的前缀 "concurrency_in_session": 1, # 同一会话最多有多少条消息在处理中,大于1可能乱序 "image_create_size": "256x256", # 图片大小,可选有 256x256, 512x512, 1024x1024 (dall-e-3默认为1024x1024) + "group_chat_exit_group": False, # chatgpt会话参数 "expires_in_seconds": 3600, # 无操作会话的过期时间 # 人格描述 diff --git a/plugins/hello/hello.py b/plugins/hello/hello.py index 80c7837..76772af 100644 --- a/plugins/hello/hello.py +++ b/plugins/hello/hello.py @@ -49,12 +49,15 @@ class Hello(Plugin): return if e_context["context"].type == ContextType.EXIT_GROUP: - e_context["context"].type = ContextType.TEXT - msg: ChatMessage = e_context["context"]["msg"] - e_context["context"].content = f'请你随机使用一种风格跟其他群用户说他违反规则"{msg.actual_user_nickname}"退出群聊。' - e_context.action = EventAction.BREAK # 事件结束,进入默认处理逻辑 + if conf().get("group_chat_exit_group", []) == True: + e_context["context"].type = ContextType.TEXT + msg: ChatMessage = e_context["context"]["msg"] + e_context["context"].content = f'请你随机使用一种风格跟其他群用户说他违反规则"{msg.actual_user_nickname}"退出群聊。' + e_context.action = EventAction.BREAK # 事件结束,进入默认处理逻辑 + return + e_context.action = EventAction.BREAK return - + if e_context["context"].type == ContextType.PATPAT: e_context["context"].type = ContextType.TEXT msg: ChatMessage = e_context["context"]["msg"]