-
-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine the invite code before filtering it #2522
Conversation
@@ -18,6 +19,13 @@ | |||
from bot.exts.filtering.filtering import Filtering | |||
|
|||
|
|||
REFINED_INVITE_CODE = re.compile( | |||
r"(?P<invite>[a-zA-Z0-9/]+)" # The supposedly real invite code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add a comment showing what an example invite code looks like? Difficult to understand what a real invite code looks like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really just a random combination of letters and numbers.
@@ -18,6 +19,13 @@ | |||
from bot.exts.filtering.filtering import Filtering | |||
|
|||
|
|||
REFINED_INVITE_CODE = re.compile( | |||
r"(?P<invite>[a-zA-Z0-9/]+)" # The supposedly real invite code. | |||
r"(?:[^a-zA-Z0-9/].*)?" # Ignoring anything that may come after an invalid character. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That isn't quite how discord link parsing works.
Refines the invite to what it is most likely to be. If the refining process changes the invite code, then that means it originally wasn't a valid invite code. So the refining can find that the invite is actually whitelisted, or maybe it is explictly denied and that there's a specific action that needs to be taken.
For exmaple, for
discord.gg/python.
it will ignore the dot at the end.Forward slashes (after discord.gg/) are included in the invite code because it can confuse Discord, so the behavior of blocking these invites stays unchanged for now.