-
-
Notifications
You must be signed in to change notification settings - Fork 24
Conversation
naff/client/utils/text_utils.py
Outdated
return query.match(text) is not None | ||
elif isinstance(query, models.BaseUser): | ||
# mentions with <@!ID> aren't detected without the replacement | ||
return (query.mention in text.replace("@!", "@")) or (query.username in text) |
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.
Why are you checking if the username is in the text? LordOfPolls
isn't a mention <@174918559539920897>
is
Further, if you removed that superfluous check you could squash this and the below if statements into one
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.
I don't want to check for (Discord) mentions, but for the presence itself (if it makes sense).
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 seems counter-intuitive to the feature's name, nor how most people would assume it works.
Assuming we did go that route, however, using display_name
would be better surely.
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.
*at least I would check for BaseUser.tag
-> LordOfPolls#1010
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 seems counter-intuitive to the feature's name, nor how most people would assume it works.
Assuming we did go that route, however, using
display_name
would be better surely.
Any other suggestions for the features name?
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.
I would suggest removing the username detection and keeping the name as it is. ;)
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.
Username detection really feels prone to false positives. I definitely wouldn't want it by default.
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.
like so?
NAFF/naff/client/utils/text_utils.py
Lines 23 to 25 in da514aa
elif isinstance(query, models.BaseUser): | |
# mentions with <@!ID> aren't detected without the replacement | |
return (query.mention in text.replace("@!", "@")) or (query.tag in text if const.tag_as_mention else False) |
- update `BaseUser.username` to `BaseUser.tag`
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.
Inconsequential bits, otherwise LGTM
according to @LordOfPolls Co-authored-by: LordOfPolls <[email protected]>
according to @LordOfPolls Co-authored-by: LordOfPolls <[email protected]>
according to @LordOfPolls Co-authored-by: LordOfPolls <[email protected]>
What type of pull request is this?
Description
Adds a function to check whether something was mentioned somewhere.
Changes
naff.client.utils.text_utils
Checklist
Python 3.10.x