From c27ea72c85a8b561d355700acb314f2bb1606ecd Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Mon, 30 May 2022 14:36:28 -0700 Subject: [PATCH] Add feedback for markov bot reply chance This will just send a message to the user who just updated their markov reply chance with the final value it was set to, so there are no surprises. Signed-off-by: Alek Ratzloff --- plugins/markov.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/markov.py b/plugins/markov.py index a8e285d..ba9186d 100644 --- a/plugins/markov.py +++ b/plugins/markov.py @@ -236,11 +236,20 @@ class Markov(Plugin): self.send_to(conn, channel, f"{who.nick}: {message}") case ["chance", chance]: chain = self.get_chain(channel, who.nick) - reply_chance = float(chance) + try: + reply_chance = float(chance) + except ValueError: + log.error("Couldn't parse %r as a float", chance) + return if not math.isnan(reply_chance): chain.reply_chance = min( max(float(reply_chance), 0.0), self.reply_chance ) + self.send_to( + conn, + channel, + f"{who.nick}: reply chance set to {chain.reply_chance}", + ) case _: # command not recognized pass