From 3ba75b2eb65bc03685195662383914b8f861cd37 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 11 Apr 2019 18:20:03 +0200 Subject: [PATCH] Implement DiscordCall.reply() --- royalnet/bots/discord.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/royalnet/bots/discord.py b/royalnet/bots/discord.py index f2905915..868db456 100644 --- a/royalnet/bots/discord.py +++ b/royalnet/bots/discord.py @@ -53,7 +53,18 @@ class DiscordBot: alchemy = self.alchemy async def reply(call, text: str): - raise NotImplementedError() + escaped_text = text.replace("*", "\\*") \ + .replace("_", "\\_") \ + .replace("`", "\\`") \ + .replace("[b]", "**") \ + .replace("[/b]", "**") \ + .replace("[i]", "_") \ + .replace("[/i]", "_") \ + .replace("[u]", "__") \ + .replace("[/u]", "__") \ + .replace("[c]", "`") \ + .replace("[/c]", "`") + await call.channel.send(escaped_text) async def net_request(call, message: Message, destination: str): response = await self.network.request(message, destination)