From 40326409b67fd269e0ee831f3d71b82599c4e4bd Mon Sep 17 00:00:00 2001 From: agessaman Date: Sat, 6 Sep 2025 18:52:21 -0700 Subject: [PATCH] Improve ping keyword matching with precise word boundaries --- modules/commands/base_command.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/commands/base_command.py b/modules/commands/base_command.py index 2ed5b20..850289b 100644 --- a/modules/commands/base_command.py +++ b/modules/commands/base_command.py @@ -102,11 +102,20 @@ class BaseCommand(ABC): for keyword in self.keywords: keyword_lower = keyword.lower() - # Check for exact word match or exact phrase match - if (keyword_lower == content_lower or # Exact match - content_lower.startswith(keyword_lower + ' ') or # Keyword followed by space - content_lower.endswith(' ' + keyword_lower) or # Space followed by keyword - ' ' + keyword_lower + ' ' in content_lower): # Keyword surrounded by spaces + + # Check for exact match first + if keyword_lower == content_lower: + return True + + # Check for word boundary matches using regex + import re + # Create a regex pattern that matches the keyword at word boundaries + # Use custom word boundary that treats underscores as separators + # (?