mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 16:20:02 +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
10
config.go
10
config.go
|
@ -33,6 +33,7 @@ type rule struct {
|
||||||
Actions []*ruleAction `yaml:"actions"`
|
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"`
|
MatchChannels []string `yaml:"match_channels"`
|
||||||
MatchEvent *string `yaml:"match_event"`
|
MatchEvent *string `yaml:"match_event"`
|
||||||
|
@ -169,9 +170,17 @@ func (r *rule) Matches(m *irc.Message, event *string) bool {
|
||||||
|
|
||||||
// Check whether rule is in cooldown
|
// Check whether rule is in cooldown
|
||||||
if r.Cooldown != nil && timerStore.InCooldown(r.MatcherID(), *r.Cooldown) {
|
if r.Cooldown != nil && timerStore.InCooldown(r.MatcherID(), *r.Cooldown) {
|
||||||
|
var userHasSkipBadge bool
|
||||||
|
for _, b := range r.SkipCooldownFor {
|
||||||
|
if badges.Has(b) {
|
||||||
|
userHasSkipBadge = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !userHasSkipBadge {
|
||||||
logger.Trace("Non-Match: On cooldown")
|
logger.Trace("Non-Match: On cooldown")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if r.DisableOnOffline {
|
if r.DisableOnOffline {
|
||||||
streamLive, err := twitch.HasLiveStream(m.Params[0])
|
streamLive, err := twitch.HasLiveStream(m.Params[0])
|
||||||
|
@ -180,6 +189,7 @@ func (r *rule) Matches(m *irc.Message, event *string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !streamLive {
|
if !streamLive {
|
||||||
|
logger.Trace("Non-Match: Stream offline")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,9 @@ rules: # See below for examples
|
||||||
# Add a cooldown to the command (not to trigger counters twice, ...)
|
# Add a cooldown to the command (not to trigger counters twice, ...)
|
||||||
cooldown: 1s # Duration value: 1s / 1m / 1h
|
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 actions when the matched channel has no active stream
|
||||||
disable_on_offline: false
|
disable_on_offline: false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue