From 26540bfb636d81af219a320cf52678925f664992 Mon Sep 17 00:00:00 2001 From: zhanws Date: Wed, 29 Mar 2023 01:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E8=AF=AD=E9=9F=B3=E5=8D=95?= =?UTF-8?q?=E8=81=8A=E5=89=8D=E7=BC=80=E5=88=A4=E6=96=AD=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=20(#661)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channel/wechat/wechat_channel.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index 49dc9fc..28d8fb6 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -282,7 +282,7 @@ class WechatChannel(Channel): if reply.type != ReplyType.ERROR and reply.type != ReplyType.INFO: content = reply.content # 语音转文字后,将文字内容作为新的context context.type = ContextType.TEXT - if context["isgroup"]: + if context["isgroup"]: # 群聊 # 校验关键字 match_prefix = check_prefix(content, conf().get('group_chat_prefix')) match_contain = check_contain(content, conf().get('group_chat_keyword')) @@ -293,7 +293,14 @@ class WechatChannel(Channel): else: logger.info("[WX]receive voice, checkprefix didn't match") return - + else: # 单聊 + match_prefix = check_prefix(content, conf().get('single_chat_prefix')) + if match_prefix: # 判断如果匹配到自定义前缀,则返回过滤掉前缀+空格后的内容 + content = content.replace(match_prefix, '', 1).strip() + else: + logger.info("[WX]receive voice, checkprefix didn't match") + return + img_match_prefix = check_prefix(content, conf().get('image_create_prefix')) if img_match_prefix: content = content.replace(img_match_prefix, '', 1).strip()