mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-21 14:17:11 +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]
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user