This commit is contained in:
Bakadax
2025-04-06 14:30:43 +08:00
parent 594c30ab74
commit 2dd44ec69c
5 changed files with 56 additions and 7 deletions

View File

@@ -42,11 +42,15 @@ def is_mentioned_bot_in_message(message: MessageRecv) -> bool:
"""检查消息是否提到了机器人"""
keywords = [global_config.BOT_NICKNAME]
nicknames = global_config.BOT_ALIAS_NAMES
if f"回复{global_config.BOT_NICKNAME}({global_config.BOT_QQ})的消息,说: " in message.processed_plain_text:
return True
message_content = re.sub(r'\@[\s\S]*?\((\d+)\)','', message.processed_plain_text)
message_content = re.sub(r'回复[\s\S]*?\((\d+)\)的消息,说: ','', message_content)
for keyword in keywords:
if keyword in message.processed_plain_text:
if keyword in message_content:
return True
for nickname in nicknames:
if nickname in message.processed_plain_text:
if nickname in message_content:
return True
return False