From 623f841faad65a5d1b9b2326403ba618997fa923 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 22 Oct 2019 00:12:09 +0200 Subject: [PATCH] replace codeblock and insert zero width joiner next to stray backticks - replace simple codeblocks (`) with multiline codeblocks (```) - add a zero width joiner (U+200D) after every backtick in the message content effectively canceling any formatting done by it Should fix #17 --- cogs/logs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cogs/logs.py b/cogs/logs.py index 6cd498c..ec9217b 100644 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -211,11 +211,15 @@ class Logs(Cog): await self.do_spy(after) + # U+200D is a Zero Width Joiner stopping backticks from breaking the formatting + before_content = before.clean_content.replace("`", "`\u200d") + after_content = after.clean_content.replace("`", "`\u200d") + log_channel = self.bot.get_channel(config.log_channel) msg = "📝 **Message edit**: \n"\ f"from {self.bot.escape_message(after.author.name)} "\ f"({after.author.id}), in {after.channel.mention}:\n"\ - f"`{before.clean_content}` → `{after.clean_content}`" + f"```{before.clean_content}``` → ```{after.clean_content}```" # If resulting message is too long, upload to hastebin if len(msg) > 2000: