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
This commit is contained in:
parent
f5acc27ccd
commit
623f841faa
1 changed files with 5 additions and 1 deletions
|
@ -211,11 +211,15 @@ class Logs(Cog):
|
||||||
|
|
||||||
await self.do_spy(after)
|
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)
|
log_channel = self.bot.get_channel(config.log_channel)
|
||||||
msg = "📝 **Message edit**: \n"\
|
msg = "📝 **Message edit**: \n"\
|
||||||
f"from {self.bot.escape_message(after.author.name)} "\
|
f"from {self.bot.escape_message(after.author.name)} "\
|
||||||
f"({after.author.id}), in {after.channel.mention}:\n"\
|
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 resulting message is too long, upload to hastebin
|
||||||
if len(msg) > 2000:
|
if len(msg) > 2000:
|
||||||
|
|
Loading…
Reference in a new issue