oopsie fix url stuff

This commit is contained in:
2025-08-29 22:23:52 +01:00
parent 624eae6c33
commit 4f772b5657

6
bot.py
View File

@@ -22,11 +22,11 @@ async def on_message(message):
if message.author == bot.user:
return
# Check if the message contains "nixos" (case-insensitive, as a whole word)
# Check if the message contains "nixos" (case-insensitive, as a whole word, not in a URL)
if re.search(r'\bnixos\b', message.content, re.IGNORECASE):
# Replace "nixos" with "fagOS" (preserving case of the first letter)
# Replace "nixos" with "fagOS" (preserving case of the first letter), but exclude URLs
new_content = re.sub(
r'\b(nixos)\b',
r'(?<!https?://\S*)\b(nixos)\b(?!\S*\/)',
lambda m: 'FagOS' if m.group(1)[0].isupper() else 'fagOS',
message.content,
flags=re.IGNORECASE