From 6a218030a089294278e83b8fa3089d3885fe14f7 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 6 Mar 2021 01:35:20 +0100 Subject: [PATCH] Add counter_set support Signed-off-by: Knut Ahlers --- action_counter.go | 7 +++++++ config.go | 1 + wiki/Home.md | 1 + 3 files changed, 9 insertions(+) diff --git a/action_counter.go b/action_counter.go index ff3fef8..442864e 100644 --- a/action_counter.go +++ b/action_counter.go @@ -16,6 +16,13 @@ func init() { return errors.Wrap(err, "preparing response") } + if r.CounterSet != nil { + return errors.Wrap( + store.UpdateCounter(counterName, *r.CounterSet, true), + "set counter", + ) + } + var counterStep int64 = 1 if r.CounterStep != nil { counterStep = *r.CounterStep diff --git a/config.go b/config.go index 66a50ee..62d6909 100644 --- a/config.go +++ b/config.go @@ -179,6 +179,7 @@ func (r *rule) Matches(m *irc.Message, event *string) bool { type ruleAction struct { Ban *string `json:"ban" yaml:"ban"` Command []string `json:"command" yaml:"command"` + CounterSet *int64 `json:"counter_set" yaml:"counter_set"` CounterStep *int64 `json:"counter_step" yaml:"counter_step"` Counter *string `json:"counter" yaml:"counter"` DeleteMessage *bool `json:"delete_message" yaml:"delete_message"` diff --git a/wiki/Home.md b/wiki/Home.md index 173569a..383ae50 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -24,6 +24,7 @@ rules: # See below for examples # Modify an internal counter value (does NOT send a chat line) - counter: "counterid" # String to identify the counter, applies templating + counter_set: 25 # Integer, set counter to value (counter_step is ignored if set) counter_step: 1 # Integer, can be negative or positive, default: +1 # Issue a delete on the message caught