misc_reactions: fix weights

This commit is contained in:
dece 2020-11-06 12:38:07 +01:00
parent 0558fb7bdf
commit 7f75b15207

View file

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