mirror of https://github.com/velour/catbase.git
commit
885fe097c0
|
@ -93,6 +93,7 @@ type Config struct {
|
||||||
Reaction struct {
|
Reaction struct {
|
||||||
GeneralChance float64
|
GeneralChance float64
|
||||||
HarrassChance float64
|
HarrassChance float64
|
||||||
|
NegativeHarrassmentMultiplier int
|
||||||
HarrassList []string
|
HarrassList []string
|
||||||
PositiveReactions []string
|
PositiveReactions []string
|
||||||
NegativeReactions []string
|
NegativeReactions []string
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
"Reaction" : {
|
"Reaction" : {
|
||||||
"GeneralChance": 0.01,
|
"GeneralChance": 0.01,
|
||||||
"HarrassChance": 0.05,
|
"HarrassChance": 0.05,
|
||||||
|
"NegativeHarrassmentMultiplier": 2,
|
||||||
"HarrassList": ["msherms"],
|
"HarrassList": ["msherms"],
|
||||||
"PositiveReactions": ["+1", "authorized", "aw_yea","joy"],
|
"PositiveReactions": ["+1", "authorized", "aw_yea","joy"],
|
||||||
"NegativeReactions": ["bullshit","fake","tableflip","vomit"]
|
"NegativeReactions": ["bullshit","fake","tableflip","vomit"]
|
||||||
|
|
|
@ -26,27 +26,40 @@ func New(bot bot.Bot) *ReactionPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ReactionPlugin) Message(message msg.Message) bool {
|
func (p *ReactionPlugin) Message(message msg.Message) bool {
|
||||||
outOf := int(1. / p.Config.Reaction.GeneralChance)
|
harrass := false
|
||||||
|
|
||||||
for _, reaction := range p.Config.Reaction.PositiveReactions {
|
|
||||||
if rand.Intn(outOf) == 0 {
|
|
||||||
p.Bot.React(message.Channel, reaction, message)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, nick := range p.Config.Reaction.HarrassList {
|
for _, nick := range p.Config.Reaction.HarrassList {
|
||||||
if message.User.Name == nick {
|
if message.User.Name == nick {
|
||||||
outOf = int(1. / p.Config.Reaction.HarrassChance)
|
harrass = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, reaction := range p.Config.Reaction.NegativeReactions {
|
chance := p.Config.Reaction.GeneralChance
|
||||||
if rand.Intn(outOf) == 0 {
|
negativeWeight := 1
|
||||||
p.Bot.React(message.Channel, reaction, message)
|
if harrass {
|
||||||
return false
|
chance = p.Config.Reaction.HarrassChance
|
||||||
|
negativeWeight = p.Config.Reaction.NegativeHarrassmentMultiplier
|
||||||
|
}
|
||||||
|
|
||||||
|
if rand.Float64() < chance {
|
||||||
|
numPositiveReactions := len(p.Config.Reaction.PositiveReactions)
|
||||||
|
numNegativeReactions := len(p.Config.Reaction.NegativeReactions)
|
||||||
|
|
||||||
|
maxIndex := numPositiveReactions + numNegativeReactions * negativeWeight
|
||||||
|
|
||||||
|
index := rand.Intn(maxIndex)
|
||||||
|
|
||||||
|
reaction := ""
|
||||||
|
|
||||||
|
if index < numPositiveReactions {
|
||||||
|
reaction = p.Config.Reaction.PositiveReactions[index]
|
||||||
|
} else {
|
||||||
|
index -= numPositiveReactions
|
||||||
|
index %= numNegativeReactions
|
||||||
|
reaction = p.Config.Reaction.NegativeReactions[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.Bot.React(message.Channel, reaction, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue