Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for group chat session IDs in configuration and log… #2355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion channel/chat_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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可能没有赋值
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, # 是否允许机器人触发
Expand Down