mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-21 06:07:13 +08:00
check_prefix函数跑到外面了
This commit is contained in:
@@ -290,16 +290,15 @@ class WechatChannel(Channel):
|
|||||||
context.type = ContextType.TEXT
|
context.type = ContextType.TEXT
|
||||||
if (context["isgroup"] == True):
|
if (context["isgroup"] == True):
|
||||||
# 校验关键字
|
# 校验关键字
|
||||||
match_prefix = self.check_prefix(content, conf().get('group_chat_prefix')) \
|
match_prefix = check_prefix(content, conf().get('group_chat_prefix')) \
|
||||||
or self.check_contain(content, conf().get('group_chat_keyword'))
|
or check_contain(content, conf().get('group_chat_keyword'))
|
||||||
# Wechaty判断is_at为True,返回的内容是过滤掉@之后的内容;而is_at为False,则会返回完整的内容
|
# Wechaty判断is_at为True,返回的内容是过滤掉@之后的内容;而is_at为False,则会返回完整的内容
|
||||||
if match_prefix is not None:
|
if match_prefix is not None:
|
||||||
# 故判断如果匹配到自定义前缀,则返回过滤掉前缀+空格后的内容,用于实现类似自定义+前缀触发生成AI图片的功能
|
# 故判断如果匹配到自定义前缀,则返回过滤掉前缀+空格后的内容,用于实现类似自定义+前缀触发生成AI图片的功能
|
||||||
prefixes = conf().get('group_chat_prefix')
|
prefixes = conf().get('group_chat_prefix')
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
if content.startswith(prefix):
|
if content.startswith(prefix):
|
||||||
content = content.replace(
|
content = content.replace(prefix, '', 1).strip()
|
||||||
prefix, '', 1).strip()
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
logger.info("[WX]receive voice check prefix: " + 'False')
|
logger.info("[WX]receive voice check prefix: " + 'False')
|
||||||
|
|||||||
Reference in New Issue
Block a user