picker: make picker less fair

This commit is contained in:
Chris Sexton 2021-02-02 16:02:04 -05:00 committed by Chris Sexton
parent 8cb6b485cb
commit 9345e83adf
1 changed files with 11 additions and 0 deletions

View File

@ -45,6 +45,17 @@ func (p *PickerPlugin) message(c bot.Connector, kind bot.Kind, message msg.Messa
return true return true
} }
preferences := p.bot.Config().GetArray("picker.preferences", []string{})
for _, it := range items {
for _, pref := range preferences {
if pref == it {
out := fmt.Sprintf("I've chosen %q for you.", strings.TrimSpace(it))
p.bot.Send(c, bot.Message, message.Channel, out)
return true
}
}
}
if n == 1 { if n == 1 {
item := items[rand.Intn(len(items))] item := items[rand.Intn(len(items))]
out := fmt.Sprintf("I've chosen %q for you.", strings.TrimSpace(item)) out := fmt.Sprintf("I've chosen %q for you.", strings.TrimSpace(item))