From ebcb532c38be49853ed1b7fc240de034b4cef1a9 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 16 Dec 2015 23:46:02 -0500 Subject: [PATCH] Change regex from \d+ to [0-9]+ for performance reasons. \d+ includes unicode characters while [0-9]+ doesn't. --- discord/client.py | 2 +- discord/message.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/client.py b/discord/client.py index 64ceb8c9c..ed87c0e61 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 f4ff05860..f259032d7 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