From 70ff2341cb84011048ae788d0e322e3ad9f9ab3d Mon Sep 17 00:00:00 2001 From: 6vision Date: Wed, 26 Jun 2024 22:10:58 +0800 Subject: [PATCH 1/2] fix:dingtalk channel group chat bug --- channel/chat_channel.py | 1 + channel/dingtalk/dingtalk_message.py | 1 + 2 files changed, 2 insertions(+) diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 6e2a45c..27f3af0 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -117,6 +117,7 @@ class ChatChannel(Channel): logger.info("[chat_channel]receive group at") if not conf().get("group_at_off", False): flag = True + self.name = self.name if self.name is not None else "" # 部分渠道self.name可能没有赋值 pattern = f"@{re.escape(self.name)}(\u2005|\u0020)" subtract_res = re.sub(pattern, r"", content) if isinstance(context["msg"].at_list, list): diff --git a/channel/dingtalk/dingtalk_message.py b/channel/dingtalk/dingtalk_message.py index 1bba85d..7806907 100644 --- a/channel/dingtalk/dingtalk_message.py +++ b/channel/dingtalk/dingtalk_message.py @@ -49,6 +49,7 @@ class DingTalkMessage(ChatMessage): if self.is_group: self.from_user_id = event.conversation_id self.actual_user_id = event.sender_id + self.is_at = True # 群聊内,只有被艾特时候才会收到消息 else: self.from_user_id = event.sender_id self.actual_user_id = event.sender_id From 91f5ffb2d9542066f756b1a210dbeff0072e79dc Mon Sep 17 00:00:00 2001 From: 6vision Date: Wed, 26 Jun 2024 22:34:35 +0800 Subject: [PATCH 2/2] Correct the log information --- channel/dingtalk/dingtalk_channel.py | 2 +- channel/dingtalk/dingtalk_message.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/channel/dingtalk/dingtalk_channel.py b/channel/dingtalk/dingtalk_channel.py index cbe522f..9128d95 100644 --- a/channel/dingtalk/dingtalk_channel.py +++ b/channel/dingtalk/dingtalk_channel.py @@ -163,7 +163,7 @@ class DingTalkChanel(ChatChannel, dingtalk_stream.ChatbotHandler): elif cmsg.ctype == ContextType.PATPAT: logger.debug("[DingTalk]receive patpat msg: {}".format(cmsg.content)) elif cmsg.ctype == ContextType.TEXT: - logger.debug("[DingTalk]receive patpat msg: {}".format(cmsg.content)) + logger.debug("[DingTalk]receive text msg: {}".format(cmsg.content)) else: logger.debug("[DingTalk]receive other msg: {}".format(cmsg.content)) context = self._compose_context(cmsg.ctype, cmsg.content, isgroup=True, msg=cmsg) diff --git a/channel/dingtalk/dingtalk_message.py b/channel/dingtalk/dingtalk_message.py index 7806907..c069a1b 100644 --- a/channel/dingtalk/dingtalk_message.py +++ b/channel/dingtalk/dingtalk_message.py @@ -49,7 +49,7 @@ class DingTalkMessage(ChatMessage): if self.is_group: self.from_user_id = event.conversation_id self.actual_user_id = event.sender_id - self.is_at = True # 群聊内,只有被艾特时候才会收到消息 + self.is_at = True else: self.from_user_id = event.sender_id self.actual_user_id = event.sender_id