mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-03 08:54:50 +08:00
feat: add group_at_off and group_chat_reply_prefix config #35
This commit is contained in:
@@ -89,7 +89,8 @@ class WechatChannel(Channel):
|
||||
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 @@ class WechatChannel(Channel):
|
||||
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 @@ class WechatChannel(Channel):
|
||||
return prefix
|
||||
return None
|
||||
|
||||
|
||||
def check_contain(self, content, keyword_list):
|
||||
if not keyword_list:
|
||||
return None
|
||||
@@ -160,4 +163,3 @@ class WechatChannel(Channel):
|
||||
if content.find(ky) != -1:
|
||||
return True
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user