From 4ff87abda66ac8c6b988477c03fd7163f95e259f Mon Sep 17 00:00:00 2001 From: ionite34 Date: Tue, 16 Aug 2022 18:29:48 -0400 Subject: Added regex for leading https or www --- botcore/utils/regex.py | 1 + 1 file changed, 1 insertion(+) (limited to 'botcore') diff --git a/botcore/utils/regex.py b/botcore/utils/regex.py index 56c50dad..e074a342 100644 --- a/botcore/utils/regex.py +++ b/botcore/utils/regex.py @@ -3,6 +3,7 @@ import re DISCORD_INVITE = re.compile( + r"((https?://)?(www\.)?)?" r"(discord([.,]|dot)gg|" # Could be discord.gg/ r"discord([.,]|dot)com(/|slash)invite|" # or discord.com/invite/ r"discordapp([.,]|dot)com(/|slash)invite|" # or discordapp.com/invite/ -- cgit v1.2.3 From 360ef04dba45950c013e4aee9ab63d0dc5386000 Mon Sep 17 00:00:00 2001 From: ionite34 Date: Tue, 16 Aug 2022 18:31:38 -0400 Subject: Removed a redundant regex character class --- botcore/utils/regex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'botcore') diff --git a/botcore/utils/regex.py b/botcore/utils/regex.py index e074a342..76311ca7 100644 --- a/botcore/utils/regex.py +++ b/botcore/utils/regex.py @@ -11,7 +11,7 @@ DISCORD_INVITE = re.compile( r"discord([.,]|dot)li|" # or discord.li r"discord([.,]|dot)io|" # or discord.io. r"((?\S+)", # the invite code itself flags=re.IGNORECASE ) -- cgit v1.2.3 From 11327c6d9e9e702afe5e3dfa158fa78251d87e9b Mon Sep 17 00:00:00 2001 From: ionite34 Date: Tue, 16 Aug 2022 18:41:49 -0400 Subject: Unified usage of flags kwarg --- botcore/utils/regex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'botcore') diff --git a/botcore/utils/regex.py b/botcore/utils/regex.py index 76311ca7..b13b0408 100644 --- a/botcore/utils/regex.py +++ b/botcore/utils/regex.py @@ -33,7 +33,7 @@ FORMATTED_CODE_REGEX = re.compile( r"(?P.*?)" # extract all code inside the markup r"\s*" # any more whitespace before the end of the code markup r"(?P=delim)", # match the exact same delimiter from the start again - re.DOTALL | re.IGNORECASE # "." also matches newlines, case insensitive + flags=re.DOTALL | re.IGNORECASE # "." also matches newlines, case insensitive ) """ Regex for formatted code, using Discord's code blocks. @@ -45,7 +45,7 @@ RAW_CODE_REGEX = re.compile( r"^(?:[ \t]*\n)*" # any blank (empty or tabs/spaces only) lines before the code r"(?P.*?)" # extract all the rest as code r"\s*$", # any trailing whitespace until the end of the string - re.DOTALL # "." also matches newlines + flags=re.DOTALL # "." also matches newlines ) """ Regex for raw code, *not* using Discord's code blocks. -- cgit v1.2.3 From d8735bc057d2100ecabcd49827b94ae0ceaf224f Mon Sep 17 00:00:00 2001 From: ionite34 Date: Tue, 16 Aug 2022 18:44:39 -0400 Subject: Removed redundant capture group --- botcore/utils/regex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'botcore') diff --git a/botcore/utils/regex.py b/botcore/utils/regex.py index b13b0408..4f91d3e0 100644 --- a/botcore/utils/regex.py +++ b/botcore/utils/regex.py @@ -3,7 +3,7 @@ import re DISCORD_INVITE = re.compile( - r"((https?://)?(www\.)?)?" + r"(https?://)?(www\.)?" r"(discord([.,]|dot)gg|" # Could be discord.gg/ r"discord([.,]|dot)com(/|slash)invite|" # or discord.com/invite/ r"discordapp([.,]|dot)com(/|slash)invite|" # or discordapp.com/invite/ -- cgit v1.2.3 From 8330044eae8c7d40151538d7403f97ca22759640 Mon Sep 17 00:00:00 2001 From: ionite34 Date: Tue, 16 Aug 2022 19:11:29 -0400 Subject: Added comments for regex addition --- botcore/utils/regex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'botcore') diff --git a/botcore/utils/regex.py b/botcore/utils/regex.py index 4f91d3e0..de82a1ed 100644 --- a/botcore/utils/regex.py +++ b/botcore/utils/regex.py @@ -3,7 +3,7 @@ import re DISCORD_INVITE = re.compile( - r"(https?://)?(www\.)?" + r"(https?://)?(www\.)?" # Optional http(s) and www. r"(discord([.,]|dot)gg|" # Could be discord.gg/ r"discord([.,]|dot)com(/|slash)invite|" # or discord.com/invite/ r"discordapp([.,]|dot)com(/|slash)invite|" # or discordapp.com/invite/ -- cgit v1.2.3