From 7ab56b90767eb093db8865a47f39e872d67cec28 Mon Sep 17 00:00:00 2001 From: chenzhenkun Date: Fri, 1 Sep 2023 18:56:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BB=A5=E6=96=B9=E4=BE=BF=E5=AE=9A=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channel/chat_channel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 83853df..be75ebb 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -103,6 +103,7 @@ class ChatChannel(Channel): flag = True if match_prefix: content = content.replace(match_prefix, "", 1).strip() + logger.info(f'context["msg"]: {context["msg"].__str__()}') if context["msg"].is_at and context["msg"].to_user_id != context["msg"].actual_user_id: logger.info("[WX]receive group at") if not conf().get("group_at_off", False): From 79be4530d49469f37b52bdeddd5bf4c1fa546f83 Mon Sep 17 00:00:00 2001 From: chenzhenkun Date: Fri, 1 Sep 2023 19:18:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=91=BD=E4=B8=AD?= =?UTF-8?q?=E5=89=8D=E7=BC=80=E5=AF=BC=E8=87=B4=E6=AD=BB=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channel/chat_channel.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/channel/chat_channel.py b/channel/chat_channel.py index be75ebb..e83ebe6 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -99,25 +99,25 @@ class ChatChannel(Channel): match_prefix = check_prefix(content, conf().get("group_chat_prefix")) match_contain = check_contain(content, conf().get("group_chat_keyword")) flag = False - if match_prefix is not None or match_contain is not None: - flag = True - if match_prefix: - content = content.replace(match_prefix, "", 1).strip() - logger.info(f'context["msg"]: {context["msg"].__str__()}') - if context["msg"].is_at and context["msg"].to_user_id != context["msg"].actual_user_id: - logger.info("[WX]receive group at") - if not conf().get("group_at_off", False): + if context["msg"].to_user_id != context["msg"].actual_user_id: + if match_prefix is not None or match_contain is not None: flag = True - pattern = f"@{re.escape(self.name)}(\u2005|\u0020)" - subtract_res = re.sub(pattern, r"", content) - for at in context["msg"].at_list: - pattern = f"@{re.escape(at)}(\u2005|\u0020)" - subtract_res = re.sub(pattern, r"", subtract_res) - if subtract_res == content and context["msg"].self_display_name: - # 前缀移除后没有变化,使用群昵称再次移除 - pattern = f"@{re.escape(context['msg'].self_display_name)}(\u2005|\u0020)" + if match_prefix: + content = content.replace(match_prefix, "", 1).strip() + if context["msg"].is_at: + logger.info("[WX]receive group at") + if not conf().get("group_at_off", False): + flag = True + pattern = f"@{re.escape(self.name)}(\u2005|\u0020)" subtract_res = re.sub(pattern, r"", content) - content = subtract_res + for at in context["msg"].at_list: + pattern = f"@{re.escape(at)}(\u2005|\u0020)" + subtract_res = re.sub(pattern, r"", subtract_res) + if subtract_res == content and context["msg"].self_display_name: + # 前缀移除后没有变化,使用群昵称再次移除 + pattern = f"@{re.escape(context['msg'].self_display_name)}(\u2005|\u0020)" + subtract_res = re.sub(pattern, r"", content) + content = subtract_res if not flag: if context["origin_ctype"] == ContextType.VOICE: logger.info("[WX]receive group voice, but checkprefix didn't match") From ac4adac29e9371c0da2209843002257d9ec95275 Mon Sep 17 00:00:00 2001 From: chenzhenkun Date: Fri, 1 Sep 2023 19:37:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E8=89=BE=E7=89=B9=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channel/wework/wework_message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/channel/wework/wework_message.py b/channel/wework/wework_message.py index 3daf232..bd08091 100644 --- a/channel/wework/wework_message.py +++ b/channel/wework/wework_message.py @@ -157,7 +157,9 @@ class WeworkMessage(ChatMessage): at_list = tmp_list logger.debug(f"at_list: {at_list}") logger.debug(f"nickname: {nickname}") - self.is_at = nickname in at_list + self.is_at = False + if nickname in at_list or login_info['nickname'] in at_list or login_info['username'] in at_list: + self.is_at = True self.at_list = at_list # 检查消息内容是否包含@用户名。处理复制粘贴的消息,这类消息可能不会触发@通知,但内容中可能包含 "@用户名"。