From 6a402f315b49461c94fab08ee1fb2300bf7d1a17 Mon Sep 17 00:00:00 2001 From: Sacha Bron Date: Thu, 31 Mar 2022 22:44:37 +0200 Subject: [PATCH] Add chat detection to avoid using dash --- cambot/wordle.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cambot/wordle.py b/cambot/wordle.py index ea4580f..55ed24a 100644 --- a/cambot/wordle.py +++ b/cambot/wordle.py @@ -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 !")