add reactions on keywords functionality

Fixes #52
This commit is contained in:
Abigail 2019-12-23 11:32:02 -05:00
parent c47fd0549d
commit c48a4069cb
2 changed files with 14 additions and 0 deletions

10
main.py
View File

@ -115,6 +115,16 @@ async def on_ready():
print("------") print("------")
@bot.event
async def on_message(message):
msg = message.content.lower()
for emoji, keywords in opt.msg_reacts.items():
if any([keyword in msg for keyword in keywords]):
await message.add_reaction(discord.utils.find(lambda x: x.id == emoji, bot.emojis))
await bot.process_commands(message)
# --- Tasks --- # --- Tasks ---
@tasks.loop(minutes=5) @tasks.loop(minutes=5)

View File

@ -31,3 +31,7 @@ exts = ['ae7q', 'base', 'fun', 'grid', 'ham', 'image', 'lookup', 'morse', 'qrz',
# The text to put in the "playing" status. # The text to put in the "playing" status.
game = 'with lids on 7.200' game = 'with lids on 7.200'
# Emoji IDs and keywords for emoji reactions
# Use the format {emoji_id (int): ('tuple', 'of', 'lowercase', 'keywords')}
msg_reacts = {}