aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2021-05-07 21:17:02 +0100
committerGravatar GitHub <[email protected]>2021-05-07 21:17:02 +0100
commit90804d8a9e51708832b1e5aebc146fabe6c2da81 (patch)
treef615b56100ab1508aa6120462ff1e50d7ca0d6de
parentMerge pull request #1571 from Qwerty-133/extension (diff)
parentMerge branch 'main' into message_edit (diff)
Merge pull request #1572 from Qwerty-133/message_edit
Escape markdown in the edited message contents before getting their diff.
-rw-r--r--bot/exts/moderation/modlog.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/exts/moderation/modlog.py b/bot/exts/moderation/modlog.py
index e92f76c9a..be65ade6e 100644
--- a/bot/exts/moderation/modlog.py
+++ b/bot/exts/moderation/modlog.py
@@ -12,6 +12,7 @@ from deepdiff import DeepDiff
from discord import Colour
from discord.abc import GuildChannel
from discord.ext.commands import Cog, Context
+from discord.utils import escape_markdown
from bot.bot import Bot
from bot.constants import Categories, Channels, Colours, Emojis, Event, Guild as GuildConstant, Icons, Roles, URLs
@@ -640,9 +641,10 @@ class ModLog(Cog, name="ModLog"):
channel = msg_before.channel
channel_name = f"{channel.category}/#{channel.name}" if channel.category else f"#{channel.name}"
+ cleaned_contents = (escape_markdown(msg.clean_content).split() for msg in (msg_before, msg_after))
# Getting the difference per words and group them by type - add, remove, same
# Note that this is intended grouping without sorting
- diff = difflib.ndiff(msg_before.clean_content.split(), msg_after.clean_content.split())
+ diff = difflib.ndiff(*cleaned_contents)
diff_groups = tuple(
(diff_type, tuple(s[2:] for s in diff_words))
for diff_type, diff_words in itertools.groupby(diff, key=lambda s: s[0])