trigger on 'cw' as long as it's not in the middle of the word
This commit is contained in:
parent
c882ae9922
commit
482d26cbd4
7
bot.py
7
bot.py
|
@ -1,7 +1,10 @@
|
||||||
import discord
|
import discord
|
||||||
import io
|
import io
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
SPOILER_REGEX = re.compile(r'spoil|\bcw\b', re.IGNORECASE)
|
||||||
|
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
|
|
||||||
def mentions_me(message):
|
def mentions_me(message):
|
||||||
|
@ -16,7 +19,7 @@ async def on_message(message):
|
||||||
if message.author == client.user:
|
if message.author == client.user:
|
||||||
return
|
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 message.attachments
|
||||||
and not any(a.is_spoiler() for a in 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))
|
print('error deleting message: {0}'.format(e))
|
||||||
return
|
return
|
||||||
elif mentions_me(message):
|
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
|
@client.event
|
||||||
async def on_reaction_add(reaction, user):
|
async def on_reaction_add(reaction, user):
|
||||||
|
|
Loading…
Reference in a new issue