vfsw
This commit is contained in:
18
bot.py
18
bot.py
@@ -22,16 +22,16 @@ async def on_message(message):
|
||||
if message.author == bot.user:
|
||||
return
|
||||
|
||||
# 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), but exclude URLs
|
||||
new_content = re.sub(
|
||||
r'(?<!https?://\S*)\b(nixos)\b(?!\S*\/)',
|
||||
lambda m: 'FagOS' if m.group(1)[0].isupper() else 'fagOS',
|
||||
message.content,
|
||||
flags=re.IGNORECASE
|
||||
)
|
||||
# Replace "nixos" with "fagOS" (preserving case of the first letter), but exclude URLs starting with http(s)://
|
||||
new_content = re.sub(
|
||||
r'(https?://\S+)|(\bnixos\b)',
|
||||
lambda m: m.group(1) if m.group(1) else ('FagOS' if m.group(2)[0].isupper() else 'fagOS'),
|
||||
message.content,
|
||||
flags=re.IGNORECASE
|
||||
)
|
||||
|
||||
# Only proceed if the content was actually modified
|
||||
if new_content != message.content:
|
||||
# Get or create a webhook for impersonation
|
||||
webhooks = await message.channel.webhooks()
|
||||
webhook = next((w for w in webhooks if w.name == 'FagOSWebhook'), None)
|
||||
|
||||
Reference in New Issue
Block a user