mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 08:10:08 +00:00
Allow to specify user-groups to skip cooldown
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f6a1c33cb7
commit
c18f96f889
2 changed files with 16 additions and 3 deletions
16
config.go
16
config.go
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue