diff options
| author | 2020-03-17 09:09:20 +0200 | |
|---|---|---|
| committer | 2020-03-17 09:09:20 +0200 | |
| commit | a184b304a136d6f2e3373e475433caf7665fde6d (patch) | |
| tree | 4601b84246174891df9580c8962dad2f1daa5622 | |
| parent | Merge pull request #803 from RohanJnr/tags_overhaul (diff) | |
(!zen Command): Added exact word check before `difflib`'s matching, due matching may not count exact word as best choice.
| -rw-r--r-- | bot/cogs/utils.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index 024141d62..2ca2c028e 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -230,7 +230,16 @@ class Utils(Cog): await ctx.send(embed=embed) return - # handle if it's a search string + # Try to handle first exact word due difflib.SequenceMatched may use some other similar word instead + # exact word. + for i, line in enumerate(zen_lines): + if search_value.lower() in line.lower(): + embed.title += f" (line {i}):" + embed.description = line + await ctx.send(embed=embed) + return + + # handle if it's a search string and not exact word matcher = difflib.SequenceMatcher(None, search_value.lower()) best_match = "" |