trigger on 'cw' as long as it's not in the middle of the word

This commit is contained in:
xenofem 2021-05-23 21:42:35 -04:00
parent c882ae9922
commit 482d26cbd4

7
bot.py
View file

@ -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):