From 36105b8ff01e47e54966f4afe31670cd9e39895a Mon Sep 17 00:00:00 2001 From: zhayujie Date: Sun, 5 Feb 2023 01:30:46 +0800 Subject: [PATCH] feat: add group_at_off and group_chat_reply_prefix config #35 --- channel/wechat/wechat_channel.py | 8 +++++--- config.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index c558600e3..790640390 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -89,7 +89,8 @@ def handle_group(self, msg): content = content_list[1] config = conf() - match_prefix = msg['IsAt'] or self.check_prefix(origin_content, config.get('group_chat_prefix')) or self.check_contain(origin_content, config.get('group_chat_keyword')) + match_prefix = (msg['IsAt'] and not config.get("group_at_off", False)) or self.check_prefix(origin_content, config.get('group_chat_prefix')) \ + or self.check_contain(origin_content, config.get('group_chat_keyword')) if (group_name in config.get('group_name_white_list') or 'ALL_GROUP' in config.get('group_name_white_list') or self.check_contain(group_name, config.get('group_name_keyword_white_list'))) and match_prefix: img_match_prefix = self.check_prefix(content, conf().get('image_create_prefix')) if img_match_prefix: @@ -145,7 +146,8 @@ def _do_send_group(self, query, msg): reply_text = super().build_reply_content(query, context) reply_text = '@' + msg['ActualNickName'] + ' ' + reply_text.strip() if reply_text: - self.send(reply_text, msg['User']['UserName']) + self.send(conf().get("group_chat_reply_prefix", "") + reply_text, msg['User']['UserName']) + def check_prefix(self, content, prefix_list): for prefix in prefix_list: @@ -153,6 +155,7 @@ def check_prefix(self, content, prefix_list): return prefix return None + def check_contain(self, content, keyword_list): if not keyword_list: return None @@ -160,4 +163,3 @@ def check_contain(self, content, keyword_list): if content.find(ky) != -1: return True return None - diff --git a/config.py b/config.py index c7d798c96..19b0f55d3 100644 --- a/config.py +++ b/config.py @@ -30,4 +30,4 @@ def read_file(path): def conf(): - return config \ No newline at end of file + return config