mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-19 21:38:18 +08:00
feat: adjust some configs to be optional
This commit is contained in:
@@ -48,7 +48,7 @@ class WechatChannel(Channel):
|
||||
match_prefix = self.check_prefix(content, conf().get('single_chat_prefix'))
|
||||
if from_user_id == other_user_id and match_prefix is not None:
|
||||
# 好友向自己发送消息
|
||||
if match_prefix is not '':
|
||||
if match_prefix != '':
|
||||
str_list = content.split(match_prefix, 1)
|
||||
if len(str_list) == 2:
|
||||
content = str_list[1].strip()
|
||||
@@ -90,7 +90,7 @@ class WechatChannel(Channel):
|
||||
|
||||
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'))
|
||||
if (group_name in config.get('group_name_white_list') or 'ALL_GROUP' in config.get('group_name_white_list') or self.fuzzy_match_group_name(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'))
|
||||
if img_match_prefix:
|
||||
content = content.split(img_match_prefix, 1)[1].strip()
|
||||
@@ -154,13 +154,10 @@ class WechatChannel(Channel):
|
||||
return None
|
||||
|
||||
def check_contain(self, content, keyword_list):
|
||||
if not keyword_list:
|
||||
return None
|
||||
for ky in keyword_list:
|
||||
if content.find(ky) != -1:
|
||||
return ky
|
||||
return True
|
||||
return None
|
||||
|
||||
def fuzzy_match_group_name(self, group_name, keyword_list):
|
||||
for ky in keyword_list:
|
||||
if group_name.find(ky) != -1:
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user