diff options
| author | 2020-07-16 10:50:40 +0200 | |
|---|---|---|
| committer | 2020-07-16 10:50:40 +0200 | |
| commit | c3fb3bcbc7d61da336109941307b72bc2dd3b37e (patch) | |
| tree | 6626675bc23387f46521faf028429b2709c0a909 | |
| parent | Prevent deleting messages above the desired message. (diff) | |
| parent | Merge pull request #1045 from python-discord/bug/980/fuzzy-processing (diff) | |
Merge branch 'master' into Senjan/clean_message
| -rw-r--r-- | bot/cogs/help.py | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/bot/cogs/help.py b/bot/cogs/help.py index 70e62d590..3d1d6fd10 100644 --- a/bot/cogs/help.py +++ b/bot/cogs/help.py @@ -8,6 +8,7 @@ from typing import List, Union  from discord import Colour, Embed, Member, Message, NotFound, Reaction, User  from discord.ext.commands import Bot, Cog, Command, Context, Group, HelpCommand  from fuzzywuzzy import fuzz, process +from fuzzywuzzy.utils import full_process  from bot import constants  from bot.constants import Channels, Emojis, STAFF_ROLES @@ -145,7 +146,13 @@ class CustomHelpCommand(HelpCommand):          Will return an instance of the `HelpQueryNotFound` exception with the error message and possible matches.          """          choices = await self.get_all_help_choices() -        result = process.extractBests(string, choices, scorer=fuzz.ratio, score_cutoff=60) + +        # Run fuzzywuzzy's processor beforehand, and avoid matching if processed string is empty +        # This avoids fuzzywuzzy from raising a warning on inputs with only non-alphanumeric characters +        if (processed := full_process(string)): +            result = process.extractBests(processed, choices, scorer=fuzz.ratio, score_cutoff=60, processor=None) +        else: +            result = []          return HelpQueryNotFound(f'Query "{string}" not found.', dict(result))  |