aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/commands.py
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-08-18 17:52:36 +0100
committerGravatar GitHub <[email protected]>2022-08-18 17:52:36 +0100
commit96f84a147c5e862d6153f48b2de83613aa3bd654 (patch)
tree6962c76ff7b9a9b8b732e5663b807e4a3d70f2de /bot/utils/commands.py
parentadd more packages to .latex (diff)
parentHelp command fix, normalize suggestions for unknown commands (#1064) (diff)
Merge branch 'main' into feat/latex-enhancement
Diffstat (limited to 'bot/utils/commands.py')
-rw-r--r--bot/utils/commands.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/bot/utils/commands.py b/bot/utils/commands.py
new file mode 100644
index 00000000..7c04a25a
--- /dev/null
+++ b/bot/utils/commands.py
@@ -0,0 +1,11 @@
+from typing import Optional
+
+from rapidfuzz import process
+
+
+def get_command_suggestions(
+ all_commands: list[str], query: str, *, cutoff: int = 60, limit: int = 3
+) -> Optional[list]:
+ """Get similar command names."""
+ results = process.extract(query, all_commands, score_cutoff=cutoff, limit=limit)
+ return [result[0] for result in results]