Skip to content

Commit

Permalink
Fix emoji handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kyb3r committed Jan 9, 2019
1 parent b50c3ad commit 39b5a5a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
import datetime
import os
import re
from types import SimpleNamespace

import discord
import aiohttp
from discord.ext import commands
from discord.ext.commands.view import StringView
from colorama import init, Fore, Style
import emoji

from core.api import Github, ModmailApiClient
from core.thread import ThreadManager
Expand Down Expand Up @@ -182,12 +184,29 @@ async def on_ready(self):
else:
await self.threads.populate_cache()



async def process_modmail(self, message):
"""Processes messages sent to the bot."""

ctx = SimpleNamespace(bot=self, guild=self.modmail_guild)
converter = commands.EmojiConverter()

blocked_emoji = self.config.get('blocked_emoji', '🚫')
sent_emoji = self.config.get('sent_emoji', '✅')

if blocked_emoji not in emoji.UNICODE_EMOJI:
try:
blocked_emoji = await converter.convert(ctx, blocked_emoji.strip(':'))
except:
pass

if sent_emoji not in emoji.UNICODE_EMOJI:
try:
sent_emoji = await converter.convert(ctx, sent_emoji.strip(':'))
except:
pass

reaction = blocked_emoji if message.author.id in self.blocked_users else sent_emoji

try:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ colorama
cachetools
python-dateutil
python-box
colorthief
colorthief
emoji

0 comments on commit 39b5a5a

Please sign in to comment.