Skip to content

Commit

Permalink
fix: chat when single_chat_prefix is None
Browse files Browse the repository at this point in the history
  • Loading branch information
lanvent committed Apr 7, 2023
1 parent e6946ef commit 2ea8b4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion channel/chat_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _compose_context(self, ctype: ContextType, content, **kwargs):
logger.info("[WX]receive group voice, but checkprefix didn't match")
return None
else: # 单聊
match_prefix = check_prefix(content, conf().get('single_chat_prefix'))
match_prefix = check_prefix(content, conf().get('single_chat_prefix',['']))
if match_prefix is not None: # 判断如果匹配到自定义前缀,则返回过滤掉前缀+空格后的内容
content = content.replace(match_prefix, '', 1).strip()
elif context["origin_ctype"] == ContextType.VOICE: # 如果源消息是私聊的语音消息,允许不匹配前缀,放宽条件
Expand Down Expand Up @@ -305,6 +305,8 @@ def cancel_all_session(self):


def check_prefix(content, prefix_list):
if not prefix_list:
return None
for prefix in prefix_list:
if content.startswith(prefix):
return prefix
Expand Down

0 comments on commit 2ea8b4e

Please sign in to comment.