Skip to content
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

Trim nick passed to .duel #36

Closed
dgw opened this issue Nov 28, 2016 · 3 comments · Fixed by #52
Closed

Trim nick passed to .duel #36

dgw opened this issue Nov 28, 2016 · 3 comments · Fixed by #52
Assignees

Comments

@dgw
Copy link
Owner

dgw commented Nov 28, 2016

The following example shows the issue with failing to sanitize the nickname passed to .duel:

<dgw> ;duel DHMO++
<Kaede> dgw has increased DHMO's reputation score to 94
<Kaede> You can't duel people who don't exist!

+, for example, is not a valid character in nicknames, and should be ignored.

The other issue is that this means users can duel using actions (see #35) while simultaneously increasing their target's reputation via the rep module, but cannot use the .duel command to achieve the same goal.

A stretch objective for resolving this is to also handle -- suffixes in addition to ++. That's trickier because - is a valid character in nicknames, so there's probably some presence-checking logic required to handle that. (If it turns out to be more work than I'm willing to do before fixing the ++ issue, it'll get punted to a separate ticket.)

@dgw
Copy link
Owner Author

dgw commented Jul 1, 2017

This is actually easier than I thought it would be, based on tests. I can just import sopel-rep's validation function and use it as a filter if available. Whether I should rewrite the rep module to be properly encapsulated before implementing that method is another matter…

@dgw
Copy link
Owner Author

dgw commented Jul 27, 2017

Glad I left the implementation of this in testing for long enough to catch an issue: The external validation function returns None if it can't extract a valid nick from the passed-in string, which causes issues with the if target == bot.nick check (AttributeError: 'NoneType' object has no attribute 'lower') due to the way Sopel overrides comparisons with Identifier objects.

Solution is probably modifying sopel-rep to return '' instead of None, because returning a string (even if it's empty) makes more sense and is still False-y.

@dgw
Copy link
Owner Author

dgw commented Mar 11, 2020

So, importing verified_nick from sopel-rep wasn't really a good solution. It doesn't work properly in all cases, depending on import order and placement of files.

Long-term solution would be to convert my plugins into PyPI packages, but the kludge will be to copy-paste the function into sopel-duel so it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant