Skip to content

Commit 39b5a5a

Browse files
committed
Fix emoji handling
1 parent b50c3ad commit 39b5a5a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

bot.py

+19
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
import datetime
3030
import os
3131
import re
32+
from types import SimpleNamespace
3233

3334
import discord
3435
import aiohttp
3536
from discord.ext import commands
3637
from discord.ext.commands.view import StringView
3738
from colorama import init, Fore, Style
39+
import emoji
3840

3941
from core.api import Github, ModmailApiClient
4042
from core.thread import ThreadManager
@@ -182,12 +184,29 @@ async def on_ready(self):
182184
else:
183185
await self.threads.populate_cache()
184186

187+
188+
185189
async def process_modmail(self, message):
186190
"""Processes messages sent to the bot."""
187191

192+
ctx = SimpleNamespace(bot=self, guild=self.modmail_guild)
193+
converter = commands.EmojiConverter()
194+
188195
blocked_emoji = self.config.get('blocked_emoji', '🚫')
189196
sent_emoji = self.config.get('sent_emoji', '✅')
190197

198+
if blocked_emoji not in emoji.UNICODE_EMOJI:
199+
try:
200+
blocked_emoji = await converter.convert(ctx, blocked_emoji.strip(':'))
201+
except:
202+
pass
203+
204+
if sent_emoji not in emoji.UNICODE_EMOJI:
205+
try:
206+
sent_emoji = await converter.convert(ctx, sent_emoji.strip(':'))
207+
except:
208+
pass
209+
191210
reaction = blocked_emoji if message.author.id in self.blocked_users else sent_emoji
192211

193212
try:

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ colorama
33
cachetools
44
python-dateutil
55
python-box
6-
colorthief
6+
colorthief
7+
emoji

0 commit comments

Comments
 (0)