From e206c4809a0ef7dae7efbc22c35b6ec147385144 Mon Sep 17 00:00:00 2001 From: Adrien Abraham Date: Sun, 26 Nov 2023 16:47:36 +0100 Subject: [PATCH] improve pfouah with flumzo (????????) --- config.json.example | 3 ++- edmond/plugins/misc_reactions.py | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/config.json.example b/config.json.example index f1545cb..92f9472 100644 --- a/config.json.example +++ b/config.json.example @@ -122,7 +122,8 @@ "pfouah_sentence": "Folks, I think I'm {word}!", "pfouah1": ["doo", "da"], "pfouah2": ["lo", "di"], - "pfouah3": ["zzeld", "ddled"] + "pfouah3": ["zzel", "ddle"] + "pfouah_suffix": "d"] }, "mood": { "commands": ["calm down"], diff --git a/edmond/plugins/misc_reactions.py b/edmond/plugins/misc_reactions.py index 9ee4d12..afed8fd 100644 --- a/edmond/plugins/misc_reactions.py +++ b/edmond/plugins/misc_reactions.py @@ -1,4 +1,5 @@ import random +from typing import Optional from irc.client import NickMask @@ -32,6 +33,7 @@ class MiscReactionsPlugin(Plugin): "repeat_letters", "nudge", "pfouah", + "flumzo", ] ) @@ -181,20 +183,34 @@ class MiscReactionsPlugin(Plugin): 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.""" + def _generate_flumzo(self) -> Optional[str]: + """I'm gonna stop writing docstrings for this shit.""" if any( k not in self.config for k in ("pfouah_sentence", "pfouah1", "pfouah2", "pfouah3") ): - return - + return None 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"]) + return word - text = self.config["pfouah_sentence"].format(word=word) + def react_with_pfouah(self, event): + """Sigh and say you're feeling like a made-up word.""" + suffix = self.config.get("pfouah_suffix") + if suffix is None: + return + flumzo = self._generate_flumzo() + if flumzo is None: + return + flumzo += suffix + text = self.config["pfouah_sentence"].format(word=flumzo) self.bot.say(event.target, text) - return True + + def react_with_flumzo(self, event): + """Same as "pfouah" but the word is said on its own.""" + flumzo = self._generate_flumzo() + if flumzo is not None: + self.bot.say(event.target, flumzo)