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:
|
if message.author == bot.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if the message contains "nixos" (case-insensitive, as a whole word, not in a URL)
|
# Replace "nixos" with "fagOS" (preserving case of the first letter), but exclude URLs starting with http(s)://
|
||||||
if re.search(r'\bnixos\b', message.content, re.IGNORECASE):
|
new_content = re.sub(
|
||||||
# Replace "nixos" with "fagOS" (preserving case of the first letter), but exclude URLs
|
r'(https?://\S+)|(\bnixos\b)',
|
||||||
new_content = re.sub(
|
lambda m: m.group(1) if m.group(1) else ('FagOS' if m.group(2)[0].isupper() else 'fagOS'),
|
||||||
r'(?<!https?://\S*)\b(nixos)\b(?!\S*\/)',
|
message.content,
|
||||||
lambda m: 'FagOS' if m.group(1)[0].isupper() else 'fagOS',
|
flags=re.IGNORECASE
|
||||||
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
|
# Get or create a webhook for impersonation
|
||||||
webhooks = await message.channel.webhooks()
|
webhooks = await message.channel.webhooks()
|
||||||
webhook = next((w for w in webhooks if w.name == 'FagOSWebhook'), None)
|
webhook = next((w for w in webhooks if w.name == 'FagOSWebhook'), None)
|
||||||
|
|||||||
Reference in New Issue
Block a user