From 7f75b15207e4ac53ce92df1cddd5dd54edaf6e92 Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 6 Nov 2020 12:38:07 +0100 Subject: [PATCH] misc_reactions: fix weights --- edmond/plugins/misc_reactions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/edmond/plugins/misc_reactions.py b/edmond/plugins/misc_reactions.py index fe92a39..c893c12 100644 --- a/edmond/plugins/misc_reactions.py +++ b/edmond/plugins/misc_reactions.py @@ -54,6 +54,11 @@ class MiscReactionsPlugin(Plugin): continue reactions.append(getattr(self, f"react_with_{reaction}")) weights.append(weight) + # Normalize weights. + total_weight = sum(weights) + weights = list(map(lambda w: w / total_weight, weights)) + self.bot.log_d(f"Reactions: {reactions}") + self.bot.log_d(f"Reaction weights: {weights}") return reactions, weights def on_pubmsg(self, event):