From fa60a5dc636f21cd572c037d1daba37a887abaed Mon Sep 17 00:00:00 2001 From: 6vision Date: Thu, 19 Oct 2023 19:20:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E4=BA=BA=E5=85=A5?= =?UTF-8?q?=E7=BE=A4=E8=87=AA=E5=AE=9A=E4=B9=89=E6=AC=A2=E8=BF=8E=E8=AF=AD?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 1 + plugins/hello/hello.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/config.py b/config.py index 68e6404..3dd27f5 100644 --- a/config.py +++ b/config.py @@ -32,6 +32,7 @@ available_setting = { "group_name_white_list": ["ChatGPT测试群", "ChatGPT测试群2"], # 开启自动回复的群名称列表 "group_name_keyword_white_list": [], # 开启自动回复的群名称关键词列表 "group_chat_in_one_session": ["ChatGPT测试群"], # 支持会话上下文共享的群名称 + "group_welcome_msg": "", # 配置新人进群固定欢迎语,不配置则使用随机风格欢迎 "trigger_by_self": False, # 是否允许机器人触发 "image_create_prefix": ["画", "看", "找"], # 开启图片回复的前缀 "concurrency_in_session": 1, # 同一会话最多有多少条消息在处理中,大于1可能乱序 diff --git a/plugins/hello/hello.py b/plugins/hello/hello.py index cd19384..dcc248f 100644 --- a/plugins/hello/hello.py +++ b/plugins/hello/hello.py @@ -6,6 +6,7 @@ from bridge.reply import Reply, ReplyType from channel.chat_message import ChatMessage from common.log import logger from plugins import * +from config import conf @plugins.register( @@ -31,6 +32,13 @@ class Hello(Plugin): return if e_context["context"].type == ContextType.JOIN_GROUP: + if "group_welcome_msg" in conf(): + reply = Reply() + reply.type = ReplyType.TEXT + reply.content = conf().get("group_welcome_msg", "") + e_context["reply"] = reply + e_context.action = EventAction.BREAK_PASS # 事件结束,并跳过处理context的默认逻辑 + return e_context["context"].type = ContextType.TEXT msg: ChatMessage = e_context["context"]["msg"] e_context["context"].content = f'请你随机使用一种风格说一句问候语来欢迎新用户"{msg.actual_user_nickname}"加入群聊。'