Fix TypeError in _check_ban_regex by handling NoneType raw_message

- Add None check for text parameter in _check_ban_regex function
- Prevents TypeError when message.raw_message is None
- Fixes issue: expected string or bytes-like object, got 'NoneType'
pull/1239/head
magisk317 2025-09-17 11:28:44 +08:00
parent 750bdfe04d
commit 89fb98c7f4
1 changed files with 4 additions and 0 deletions

View File

@ -58,6 +58,10 @@ def _check_ban_regex(text: str, chat: ChatStream, userinfo: UserInfo) -> bool:
Returns:
bool: 是否匹配过滤正则
"""
# 检查text是否为None或空字符串
if text is None or not text:
return False
for pattern in global_config.message_receive.ban_msgs_regex:
if re.search(pattern, text):
chat_name = chat.group_info.group_name if chat.group_info else "私聊"