From 48233e5ed33eb3ccbf00ceff9da703890fec5d25 Mon Sep 17 00:00:00 2001 From: Adrien Abraham Date: Sun, 26 Nov 2023 00:59:56 +0100 Subject: [PATCH] misc_reactions: add pfouah generator --- config.json.example | 8 ++++++-- edmond/plugins/misc_reactions.py | 32 ++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/config.json.example b/config.json.example index 7469c67..f1545cb 100644 --- a/config.json.example +++ b/config.json.example @@ -108,7 +108,7 @@ "miscreactions": { "reactions": [ "stop", "king", "mmm", "ooo", "detector", "question_marks", - "repeat_letters", "nudge" + "repeat_letters", "nudge", "pfouah" ], "rate": 0, "stop_message": "This was your last {subject}...", @@ -118,7 +118,11 @@ "detector_process": "...", "detector_pos": "OK go on...", "detector_neg": "Halt!", - "nudging": "/me nudges {target}" + "nudging": "/me nudges {target}", + "pfouah_sentence": "Folks, I think I'm {word}!", + "pfouah1": ["doo", "da"], + "pfouah2": ["lo", "di"], + "pfouah3": ["zzeld", "ddled"] }, "mood": { "commands": ["calm down"], diff --git a/edmond/plugins/misc_reactions.py b/edmond/plugins/misc_reactions.py index 060aa7a..9ee4d12 100644 --- a/edmond/plugins/misc_reactions.py +++ b/edmond/plugins/misc_reactions.py @@ -31,6 +31,7 @@ class MiscReactionsPlugin(Plugin): "detector", "repeat_letters", "nudge", + "pfouah", ] ) @@ -160,13 +161,14 @@ class MiscReactionsPlugin(Plugin): 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): + repeated_prefix = biggest_word[:num_repeats] + while ( + (not any(letter in repeated_prefix for letter in "aeiouy")) + and len(repeated_prefix) < len(biggest_word) + ): num_repeats += 1 - repeated = biggest_word[:num_repeats] - word = biggest_word[:2] + biggest_word + repeated_prefix = biggest_word[:num_repeats] + word = repeated_prefix + biggest_word question_mark = self.config["question_mark"] reply = f"{word}{question_mark}" self.bot.say(event.target, reply) @@ -178,3 +180,21 @@ class MiscReactionsPlugin(Plugin): if reply is None: return self.bot.say(event.target, reply.format(target=nick)) + + def react_with_pfouah(self, event): + """Sigh and say you're feeling like a made-up word.""" + if any( + k not in self.config + for k in ("pfouah_sentence", "pfouah1", "pfouah2", "pfouah3") + ): + return + + length = random.choice((2, 3)) + word = random.choice(self.config["pfouah1"]) + if length == 3: + word += random.choice(self.config["pfouah2"]) + word += random.choice(self.config["pfouah3"]) + + text = self.config["pfouah_sentence"].format(word=word) + self.bot.say(event.target, text) + return True