Skip to content

Feature: suggest command usage for misspelt commands#760

Merged
Xithrius merged 34 commits into
masterfrom
feat/F4zi/CommandSuggestion
Jan 17, 2021
Merged

Feature: suggest command usage for misspelt commands#760
Xithrius merged 34 commits into
masterfrom
feat/F4zi/CommandSuggestion

Conversation

@F4zii
Copy link
Copy Markdown
Contributor

@F4zii F4zii commented Feb 18, 2020

Feature: suggest similar command(s) to a misspelt command

Resolves #742

@F4zii F4zii requested a review from a team as a code owner February 18, 2020 15:34
@F4zii F4zii requested review from manusaurio and sco1 and removed request for a team February 18, 2020 15:34
@MarkKoz MarkKoz added a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 3 - low Low Priority t: feature New feature or request labels Feb 18, 2020
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tags cog is not the right place for this since this feature is not actually related to tags. As it is, it will suggest commands when tags are fetched. This may make sense when this is triggered via the CommandNotFound error but it doesn't when using the !tags get command or any of its aliases.

You're piggybacking off the tags being fetched by the error handler when a command isn't found. Instead, the error handler should call this code more directly. It may be better to wait for #757 since that cleans up the error handler quite a bit.

Furthermore, is this handling subcommands properly? Is fuzzywuzzy good enough for this application? After all, the tags had better results with a custom algorithm.

@MarkKoz MarkKoz added the s: waiting for author Waiting for author to address a review or respond to a comment label Feb 18, 2020
@F4zii
Copy link
Copy Markdown
Contributor Author

F4zii commented Feb 18, 2020

Hey mark, as I've said, the current structure of the error_handler is a bit hard to change for that usage (since it reinvokes every misspelt command as a tag), I can wait or change its implementation if needed
I agree the tags aren't the place for this, I got a suggestion to base it there since its the easiest way, I will now work on a better way and update you 👍
I also had an idea to use the returned value from the command invoke into a useful piece of data
We can also raise an exception, which will be better for this case

Migration to error_handler.py

Suggesting misspelt commands, in progress
Since its used to get the input of the command, its not needed again
In the function (callback) call
preventing message spam by the bot when commands are misspelt
When found a similar command, the bot sent a suggestion about the full command name

This was fixed by saving the matching alias and sending it instead of sending the full command name
@F4zii
Copy link
Copy Markdown
Contributor Author

F4zii commented Feb 19, 2020

Hello, the feature is ready.
A quick question: should we suggest a few options or just the closest one?

Note: Few suggestions could result in a spam

@F4zii F4zii requested a review from MarkKoz February 19, 2020 19:19
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
The returned value was changed from True to False

If we didn't return True (sent the tag) throughout the code
It means we didn't send anything, we should return False
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/error_handler.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
get_command was changed to - display_tag, the name didn't fit,
since its not the command itself.

command_on_cooldown was taken out of display_tag to get the option to reuse it in another scope

Docstrings modified
@Xithrius
Copy link
Copy Markdown
Contributor

Xithrius commented Dec 31, 2020

I screwed up, I am sorry.

Attempting to fix.

@Xithrius Xithrius force-pushed the feat/F4zi/CommandSuggestion branch from e46693a to 9a00d70 Compare December 31, 2020 08:41
@jb3 jb3 removed request for jb3 and sco1 December 31, 2020 08:43
Since the cogs folder has been removed, the error_handler and tag cogs had to be removed and transfer into their respective places in the exts folder.
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 3, 2021

Coverage Status

Coverage decreased (-0.2%) to 57.193% when pulling 491e0b9 on feat/F4zi/CommandSuggestion into 844a1b6 on master.

@Xithrius
Copy link
Copy Markdown
Contributor

Xithrius commented Jan 3, 2021

Works with long commands and their arguments.
image

Works with the smallest commands as well.
image

So far I haven't found any bugs with this command and the way that it's implemented.

Still deciding if this should exist within mod channels at all, since it may just be noise at that point to the mods. At the same time, the error stays up for 10 seconds, so instead of having to retype/edit the command, it can be copy/pasted.

@Xithrius Xithrius requested review from MarkKoz and ikuyarihS January 3, 2021 04:55
@Xithrius
Copy link
Copy Markdown
Contributor

Xithrius commented Jan 6, 2021

A user with no roles executing a moderator+ only command along with a regular command (typed incorrectly) that anyone can execute.
image

@Xithrius
Copy link
Copy Markdown
Contributor

Xithrius commented Jan 7, 2021

This is the outcome of a recent poll. I think the conclusion that I can reach here is that only helpers and below should get command suggestions.
image

@Xithrius
Copy link
Copy Markdown
Contributor

Xithrius commented Jan 7, 2021

Here are examples of a user at different roles executing commands incorrectly.

No-role user:
image

Helper:
image

Moderator:
image

Admin:
image

@Xithrius Xithrius requested review from Akarys42 and removed request for Akarys42 January 14, 2021 18:25
@jb3 jb3 dismissed ikuyarihS’s stale review January 17, 2021 00:41

Outdated review

@Xithrius Xithrius merged commit c15bf0b into master Jan 17, 2021
@Xithrius Xithrius deleted the feat/F4zi/CommandSuggestion branch January 17, 2021 00:47
@jerbob
Copy link
Copy Markdown
Contributor

jerbob commented Jan 17, 2021

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

Labels

a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 3 - low Low Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest a list of available commands in case of typos

10 participants