Allow to specify user-groups to skip cooldown

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-03-21 14:36:28 +01:00
parent f6a1c33cb7
commit c18f96f889
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 16 additions and 3 deletions

View file

@ -32,7 +32,8 @@ func newConfigFile() configFile {
type rule struct {
Actions []*ruleAction `yaml:"actions"`
Cooldown *time.Duration `yaml:"cooldown"`
Cooldown *time.Duration `yaml:"cooldown"`
SkipCooldownFor []string `yaml:"skip_cooldown_for"`
MatchChannels []string `yaml:"match_channels"`
MatchEvent *string `yaml:"match_event"`
@ -169,8 +170,16 @@ func (r *rule) Matches(m *irc.Message, event *string) bool {
// Check whether rule is in cooldown
if r.Cooldown != nil && timerStore.InCooldown(r.MatcherID(), *r.Cooldown) {
logger.Trace("Non-Match: On cooldown")
return false
var userHasSkipBadge bool
for _, b := range r.SkipCooldownFor {
if badges.Has(b) {
userHasSkipBadge = true
}
}
if !userHasSkipBadge {
logger.Trace("Non-Match: On cooldown")
return false
}
}
if r.DisableOnOffline {
@ -180,6 +189,7 @@ func (r *rule) Matches(m *irc.Message, event *string) bool {
return false
}
if !streamLive {
logger.Trace("Non-Match: Stream offline")
return false
}
}

View file

@ -42,6 +42,9 @@ rules: # See below for examples
# Add a cooldown to the command (not to trigger counters twice, ...)
cooldown: 1s # Duration value: 1s / 1m / 1h
# Do not apply cooldown for these badges
skip_cooldown_for: [broadcaster, moderator]
# Disable actions when the matched channel has no active stream
disable_on_offline: false