aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2020-03-31 14:03:31 +0200
committerGravatar GitHub <[email protected]>2020-03-31 14:03:31 +0200
commit1eed2479c7867f72c204934041e8149231724e28 (patch)
tree706d4037b49dc9bab34b26997edd2dc10136fb41
parentMerge pull request #845 from python-discord/update-logging-levels (diff)
parentMerge branch 'master' into zen-match-fix (diff)
Merge pull request #833 from ks129/zen-match-fix
Fixed !zen command exact word matching.
Diffstat (limited to '')
-rw-r--r--bot/cogs/utils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py
index f0b1172e3..3ed471bbf 100644
--- a/bot/cogs/utils.py
+++ b/bot/cogs/utils.py
@@ -236,7 +236,17 @@ 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):
+ for word in line.split():
+ if word.lower() == search_value.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 = ""