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 <alekratz@gmail.com>
This commit is contained in:
2022-05-30 14:36:28 -07:00
parent 6a1ed5c372
commit c27ea72c85

View File

@@ -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