Browse Source

feat: add group_at_off and group_chat_reply_prefix config #35

master
zhayujie 2 years ago
parent
commit
36105b8ff0
2 changed files with 6 additions and 4 deletions
  1. +5
    -3
      channel/wechat/wechat_channel.py
  2. +1
    -1
      config.py

+ 5
- 3
channel/wechat/wechat_channel.py View File

@@ -89,7 +89,8 @@ class WechatChannel(Channel):
content = content_list[1] content = content_list[1]


config = conf() 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: 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')) img_match_prefix = self.check_prefix(content, conf().get('image_create_prefix'))
if img_match_prefix: if img_match_prefix:
@@ -145,7 +146,8 @@ class WechatChannel(Channel):
reply_text = super().build_reply_content(query, context) reply_text = super().build_reply_content(query, context)
reply_text = '@' + msg['ActualNickName'] + ' ' + reply_text.strip() reply_text = '@' + msg['ActualNickName'] + ' ' + reply_text.strip()
if reply_text: 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): def check_prefix(self, content, prefix_list):
for prefix in prefix_list: for prefix in prefix_list:
@@ -153,6 +155,7 @@ class WechatChannel(Channel):
return prefix return prefix
return None return None



def check_contain(self, content, keyword_list): def check_contain(self, content, keyword_list):
if not keyword_list: if not keyword_list:
return None return None
@@ -160,4 +163,3 @@ class WechatChannel(Channel):
if content.find(ky) != -1: if content.find(ky) != -1:
return True return True
return None return None


+ 1
- 1
config.py View File

@@ -30,4 +30,4 @@ def read_file(path):




def conf(): def conf():
return config
return config

Loading…
Cancel
Save