def _pred(message: discord.Message): early_exit = message.channel != self.ctx.channel or message.author == self.ctx.guild.me if early_exit: return False self._last_response = time.time() guess = re.sub(r'\s+', ' ', message.content.strip().lower()) guess = normalize_smartquotes(guess) for answer in answers: if the_match := answer.search(guess): if len(the_match.group(0)) >= .6 * len(guess): return True
def _pred(message: discord.Message): early_exit = message.channel != self.ctx.channel or message.author == self.ctx.guild.me if early_exit: return False self._last_response = time.time() guess = message.content.lower() guess = normalize_smartquotes(guess) for answer in answers: if " " in answer and answer in guess: # Exact matching, issue #331 return True elif any(word == answer for word in guess.split(" ")): return True return False
def test_normalize_smartquotes(): assert common_filters.normalize_smartquotes( "Should\u2018 normalize") == "Should' normalize" assert common_filters.normalize_smartquotes("Same String") == "Same String"