Skip to content

Commit c086cdf

Browse files
authored
Merge pull request #158 from avelytchko/main
2 parents f1ae41d + 30a04b4 commit c086cdf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ def is_bot_mentioned(message_text: str) -> bool:
106106
bool: True if the bot is mentioned, False otherwise.
107107
"""
108108
bot_trigger_words = ["ботяра", "bot_health"]
109-
# Remove all non-letter characters
110-
cleaned_text = ''.join(char for char in message_text.lower() if char.isalpha() or char.isspace())
111-
return any(word in cleaned_text for word in bot_trigger_words)
109+
# Remove leading/trailing whitespace and convert to lowercase
110+
cleaned_text = message_text.strip().lower()
111+
for word in bot_trigger_words:
112+
if cleaned_text.startswith(word):
113+
# Check if it's followed by space, punctuation, or is the whole message
114+
if len(cleaned_text) == len(word) or not cleaned_text[len(word)].isalpha():
115+
return True
116+
return False
112117

113118

114119
def clean_url(message_text: str) -> str:

0 commit comments

Comments
 (0)