From 482d26cbd417c3c66896c2a0b6b252ba4f4b6ffb Mon Sep 17 00:00:00 2001 From: xenofem Date: Sun, 23 May 2021 21:42:35 -0400 Subject: [PATCH] trigger on 'cw' as long as it's not in the middle of the word --- bot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index ab47f59..5195b00 100644 --- a/bot.py +++ b/bot.py @@ -1,7 +1,10 @@ import discord import io +import re import sys +SPOILER_REGEX = re.compile(r'spoil|\bcw\b', re.IGNORECASE) + client = discord.Client() def mentions_me(message): @@ -16,7 +19,7 @@ async def on_message(message): if message.author == client.user: return - if (('spoil' in message.content.lower() or mentions_me(message)) + if ((SPOILER_REGEX.search(message.content) or mentions_me(message)) and message.attachments and not any(a.is_spoiler() for a in message.attachments)): @@ -63,7 +66,7 @@ async def on_message(message): print('error deleting message: {0}'.format(e)) return elif mentions_me(message): - await message.channel.send("upload an image and put 'spoil' anywhere in the description, and I'll spoiler it for you. to delete your post, add a :x: react to it.") + await message.channel.send("upload an image and put 'spoil' or 'cw' (doesn't have to be lowercase) anywhere in the description, and I'll spoiler it for you. to delete your post, add a :x: react to it.") @client.event async def on_reaction_add(reaction, user):