diff --git a/clients/discord.py b/clients/discord.py index 0e770db..82bda32 100644 --- a/clients/discord.py +++ b/clients/discord.py @@ -18,6 +18,8 @@ ANNOUNCEMENT_PATTERN = re.compile(r'''^ Come\s+and\s+say\s+hi\s+at\s+(?P.+)\s+! $''', re.VERBOSE) +EMOJI_PATTERN = re.compile(r'lilial1\w+') + def cooldown(retries, timeout, failure): def do_cooldown(function): @@ -80,6 +82,12 @@ class DiscordClient(discord.Client): await action(server, message.author.id, message, **m.groupdict()) for cmd, resp in self.extra_commands.items(): if cmd == message.content: + def repl(m): + emoji = discord.utils.get(message.server.emojis, name=m.group(0)) + if not emoji: + emoji = discord.utils.get(self.get_all_emojis(), name=m.group(0)) + return str(emoji) if emoji else m.string + resp = EMOJI_PATTERN.sub(repl, resp) await self.send_message(message.channel, resp.format(user=message.author.mention)) def _guess_gifted_subs(self, nick, time, threshold):