From d66ece124159a230c0c132915f6f0eb09083bda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Fri, 27 Jul 2018 13:48:42 +0200 Subject: [PATCH] Enable user substitution in extra commands --- README.md | 3 ++- clients/discord.py | 2 +- clients/twitch.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 31c5266..22d5127 100644 --- a/README.md +++ b/README.md @@ -16,5 +16,6 @@ using [HTTP API](https://gitea.brno.mraveniste.cc/turbotraktor/ladylilia.com/src ### Mod-only commands * `!syncquotes` - performs synchronization of the quotes database with Twitch VODs -* `!command set COMMAND TEXT` - adds a new extra command or updates an existing one +* `!command set COMMAND TEXT` - adds a new extra command or updates an existing one + - instances of `{user}` in `TEXT` will be substituted when the command is executed * `!command unset COMMAND` - removes an existing extra command diff --git a/clients/discord.py b/clients/discord.py index c09bbb5..ab4e07c 100644 --- a/clients/discord.py +++ b/clients/discord.py @@ -60,7 +60,7 @@ 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: - await self.send_message(message.channel, resp) + await self.send_message(message.channel, resp.format(user=message.author.mention)) async def _cooldown_failure(self, server, user, message, **kwargs): await self.send_message(message.channel, diff --git a/clients/twitch.py b/clients/twitch.py index 49b4bd5..31b2d91 100644 --- a/clients/twitch.py +++ b/clients/twitch.py @@ -106,7 +106,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot): action(tags, send_response, **m.groupdict()) for cmd, resp in self.extra_commands.items(): if cmd == message: - send_response(resp) + send_response(resp.format(user=tags['display-name'])) def _add_quote(self, tags, send_response, user, id, text, game, date, **kwargs): if text[0] == text[-1] == '"':