Merge pull request #1 from BinaryBrain/feature/wordle-chat-detection

Add chat detection to avoid using dash
This commit is contained in:
Simon Junod
2022-03-31 22:52:29 +02:00
committed by GitHub

View File

@@ -60,6 +60,24 @@ class Game:
content = message.content.strip()
if (len(content) >= 1 and content[0] == "-") or self.winner or not self.target: # special char, or somebody won, or never initialized
return
# if the user is just chatting
if " " in content:
return
# if the guess is obviously not the same length (just chatting)
ratio = 2/3
if len(content) <= len(self.target) * ratio or len(self.target) <= len(content) * ratio:
return
# if the user post an emoji
if content[0] == ":":
return
# if the user post a link
if "://" in content:
return
# if the user post a gif (not sure about this one)
if len(content) == 0:
return
guess = unidecode(content).upper()
if WORDLE_FORCE_ALTERNATION and message.author == self.last_player:
await self.channel.send(f"{message.author.mention} Laisse un peu jouer les autres !")