aboutsummaryrefslogtreecommitdiffstats
path: root/botcore/regex.py
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-12-06 21:20:27 +0400
committerGravatar GitHub <[email protected]>2021-12-06 21:20:27 +0400
commitcfe4d495f7e9581fe58576cdf5e5dd9a490e52ed (patch)
treea3919899b8adbbed5822d40e2ab7dacfa084ab9c /botcore/regex.py
parentMerge pull request #1 from python-discord/mbaruh/setup (diff)
parentMove Doc Dependencies Into Dev Section (diff)
Merge pull request #2 from python-discord/docs-buildv1.1.0
Documentation
Diffstat (limited to 'botcore/regex.py')
-rw-r--r--botcore/regex.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/botcore/regex.py b/botcore/regex.py
new file mode 100644
index 00000000..cb1832d3
--- /dev/null
+++ b/botcore/regex.py
@@ -0,0 +1,21 @@
+"""Common regular expressions."""
+
+import re
+
+DISCORD_INVITE = re.compile(
+ 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/
+ r"discord([.,]|dot)me|" # or discord.me
+ r"discord([.,]|dot)li|" # or discord.li
+ r"discord([.,]|dot)io|" # or discord.io.
+ r"((?<!\w)([.,]|dot))gg" # or .gg/
+ r")([/]|slash)" # / or 'slash'
+ r"(?P<invite>[a-zA-Z0-9\-]+)", # the invite code itself
+ flags=re.IGNORECASE
+)
+"""
+Regex for discord server invites.
+
+:meta hide-value:
+"""