Convert emojis in extra commands

master
Nikola Forró 6 years ago
parent efd67c4a4b
commit 594c4c3ce1

@ -18,6 +18,8 @@ ANNOUNCEMENT_PATTERN = re.compile(r'''^
Come\s+and\s+say\s+hi\s+at\s+(?P<url>.+)\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):

Loading…
Cancel
Save