aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-06 20:14:05 -0400
committerRapptz <[email protected]>2019-04-06 20:14:05 -0400
commit9833ea82e247c0a01218d221293c9ed56b89d505 (patch)
tree70ab5a9d4fc94eab176b2170adc11bcd0d0cfed4 /discord/ext/commands
parent[commands] Disallow bot_ or cog_ commands or listeners in cogs. (diff)
downloaddiscord.py-9833ea82e247c0a01218d221293c9ed56b89d505.tar.xz
discord.py-9833ea82e247c0a01218d221293c9ed56b89d505.zip
Add helpers to escape markdown and mentions from text.
Fixes #1673
Diffstat (limited to 'discord/ext/commands')
-rw-r--r--discord/ext/commands/converter.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py
index 8676329c..0ca9096b 100644
--- a/discord/ext/commands/converter.py
+++ b/discord/ext/commands/converter.py
@@ -474,14 +474,10 @@ class clean_content(Converter):
result = pattern.sub(repl, argument)
if self.escape_markdown:
- result = re.sub(r'\\', r'\\\\', result)
- for c in ('*', '`', '_', '~', '|'):
- regex = r'\{0}(?=([\s\S]*((?<!\{0})\{0})))'.format(c)
- replace = '\{0}'.format(c)
- result = re.sub(regex, replace, result)
+ result = discord.utils.escape_markdown(result)
# Completely ensure no mentions escape:
- return re.sub(r'@(everyone|here|[!&]?[0-9]{17,21})', '@\u200b\\1', result)
+ return discord.utils.escape_mentions(result)
class _Greedy:
__slots__ = ('converter',)