mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 01:42:30 -05:00
Make some dependency changes, support Python 3.10 and 3.11 (#5611)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -32,7 +32,7 @@ from typing import (
|
||||
import aiohttp
|
||||
import discord
|
||||
from packaging.requirements import Requirement
|
||||
from fuzzywuzzy import fuzz, process
|
||||
from rapidfuzz import fuzz, process
|
||||
from rich.progress import ProgressColumn
|
||||
from rich.progress_bar import ProgressBar
|
||||
from red_commons.logging import VERBOSE, TRACE
|
||||
@@ -147,20 +147,20 @@ async def fuzzy_command_search(
|
||||
return None
|
||||
|
||||
if commands is None:
|
||||
choices = set(ctx.bot.walk_commands())
|
||||
choices = {c: c.qualified_name for c in ctx.bot.walk_commands()}
|
||||
elif isinstance(commands, collections.abc.AsyncIterator):
|
||||
choices = {c async for c in commands}
|
||||
choices = {c: c.qualified_name async for c in commands}
|
||||
else:
|
||||
choices = set(commands)
|
||||
choices = {c: c.qualified_name for c in commands}
|
||||
|
||||
# Do the scoring. `extracted` is a list of tuples in the form `(command, score)`
|
||||
# Do the scoring. `extracted` is a list of tuples in the form `(cmd_name, score, cmd)`
|
||||
extracted = process.extract(term, choices, limit=5, scorer=fuzz.QRatio)
|
||||
if not extracted:
|
||||
return None
|
||||
|
||||
# Filter through the fuzzy-matched commands.
|
||||
matched_commands = []
|
||||
for command, score in extracted:
|
||||
for __, score, command in extracted:
|
||||
if score < min_score:
|
||||
# Since the list is in decreasing order of score, we can exit early.
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user