From 84c753bd5b5737a5b210a05002e00fb4b7ad074f Mon Sep 17 00:00:00 2001 From: wangshuo16 Date: Thu, 24 Oct 2024 19:30:34 +0800 Subject: [PATCH] feat: add support for group chat session IDs in configuration and logging --- channel/chat_channel.py | 8 +++++++- config.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 7e2df3ac4..f42d56631 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -65,14 +65,17 @@ def _compose_context(self, ctype: ContextType, content, **kwargs): ] ): group_chat_in_one_session = conf().get("group_chat_in_one_session", []) + group_chat_in_one_session_id = conf().get("group_chat_in_one_session_id", []) session_id = cmsg.actual_user_id if any( [ group_name in group_chat_in_one_session, "ALL_GROUP" in group_chat_in_one_session, + group_id in group_chat_in_one_session_id, ] ): session_id = group_id + logger.info(f"Group chat in one session, group_name={group_name}, group_id={group_id}") else: logger.debug(f"No need reply, groupName not in whitelist, group_name={group_name}") return None @@ -114,7 +117,10 @@ def _compose_context(self, ctype: ContextType, content, **kwargs): logger.warning(f"[chat_channel] Nickname {nick_name} in In BlackList, ignore") return None - logger.info("[chat_channel]receive group at") + logger.info("[chat_channel]receive group at: group_name: {}; group_id: {}".format( + context["msg"].other_user_nickname, + context["msg"].other_user_id, + )) if not conf().get("group_at_off", False): flag = True self.name = self.name if self.name is not None else "" # 部分渠道self.name可能没有赋值 diff --git a/config.py b/config.py index a28c5b959..7de9592d0 100644 --- a/config.py +++ b/config.py @@ -35,6 +35,7 @@ "group_name_white_list": ["ChatGPT测试群", "ChatGPT测试群2"], # 开启自动回复的群名称列表 "group_name_keyword_white_list": [], # 开启自动回复的群名称关键词列表 "group_chat_in_one_session": ["ChatGPT测试群"], # 支持会话上下文共享的群名称 + "group_chat_in_one_session_id": [], # 支持会话上下文共享的群id "nick_name_black_list": [], # 用户昵称黑名单 "group_welcome_msg": "", # 配置新人进群固定欢迎语,不配置则使用随机风格欢迎 "trigger_by_self": False, # 是否允许机器人触发