aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-16 23:46:02 -0500
committerRapptz <[email protected]>2015-12-16 23:46:02 -0500
commitebcb532c38be49853ed1b7fc240de034b4cef1a9 (patch)
treebad1175fbc847fa4bf08f5f9db6e9346af34958c
parentAdd Server.me attribute to access the Member version of Client.user. (diff)
downloaddiscord.py-ebcb532c38be49853ed1b7fc240de034b4cef1a9.tar.xz
discord.py-ebcb532c38be49853ed1b7fc240de034b4cef1a9.zip
Change regex from \d+ to [0-9]+ for performance reasons.
\d+ includes unicode characters while [0-9]+ doesn't.
-rw-r--r--discord/client.py2
-rw-r--r--discord/message.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/discord/client.py b/discord/client.py
index 64ceb8c9..ed87c0e6 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -206,7 +206,7 @@ class Client:
if isinstance(mentions, list):
return [user.id for user in mentions]
elif mentions == True:
- return re.findall(r'<@(\d+)>', content)
+ return re.findall(r'<@([0-9]+)>', content)
else:
return []
diff --git a/discord/message.py b/discord/message.py
index f4ff0586..f259032d 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -132,7 +132,7 @@ class Message(object):
This allows you receive the user IDs of mentioned users
even in a private message context.
"""
- return re.findall(r'<@(\d+)>', self.content)
+ return re.findall(r'<@([0-9]+)>', self.content)
@utils.cached_property
def raw_channel_mentions(self):
@@ -142,7 +142,7 @@ class Message(object):
This allows you receive the channel IDs of mentioned users
even in a private message context.
"""
- return re.findall(r'<#(\d+)>', self.content)
+ return re.findall(r'<#([0-9]+)>', self.content)
def _handle_upgrades(self, channel_id):
self.server = None