From 56656dca98c9f41699399e93557c2fbb0bffaa96 Mon Sep 17 00:00:00 2001 From: dece Date: Thu, 2 Dec 2021 11:31:30 +0100 Subject: [PATCH] misc_reactions: improve stutter reaction --- edmond/plugins/misc_reactions.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/edmond/plugins/misc_reactions.py b/edmond/plugins/misc_reactions.py index be8ab27..5b6c252 100644 --- a/edmond/plugins/misc_reactions.py +++ b/edmond/plugins/misc_reactions.py @@ -150,6 +150,14 @@ class MiscReactionsPlugin(Plugin): if len(words) == 0: return biggest_word = sorted(words, key=lambda w: len(w))[-1] + num_repeats = 2 + repeated = biggest_word[:num_repeats] + while ( + (not any(letter in repeated for letter in "aeiouy")) + and len(repeated) < len(biggest_word) + ): + num_repeats += 1 + repeated = biggest_word[:num_repeats] word = biggest_word[:2] + biggest_word question_mark = self.config["question_mark"] reply = f"{word}{question_mark}"