Closed stephanrenggli closed 3 years ago
I was able to implement this using the random.choices function: Not pretty but the basics work :)
elif action == Action.SendInChannel:
weights = []
for e in value:
weights.append(e['weight'])
chosen_message = random.choices(value, weights=weights, k=1)
chosen_message = chosen_message[0]['message']
text = Template(chosen_message).safe_substitute(templates_vars)
last_sent_message = await channel.send(text, allowed_mentions=ALLOW_ALL_MENTIONS)
Would require some additional checks to make sure every message has a weight or alternatively calculate weight based on the other specified weights.
Hi, this suggestion has been fully added in 1.6 with the action var-assign-random
Cog
Describe the feature you'd like to see Add multiple possibilities for all message sending actions such as send-in-channel, dm-user, send-dm. Like this warden could randomly choose one possible response and send it.
Maybe even an optional weight/probability parameter so you can control which message is more likely to be chosen.
As the configuration is in yaml something like this could work.
Without weight.
With optional weight parameter.