From ac751605a88ef399a993eae29cb3fcf5363701a5 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 17 Sep 2021 14:49:56 +0200 Subject: [PATCH] Allow to skip cooldown on script error Signed-off-by: Knut Ahlers --- action_script.go | 5 +++-- wiki/Home.md | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/action_script.go b/action_script.go index 333a224..2122e3e 100644 --- a/action_script.go +++ b/action_script.go @@ -18,7 +18,8 @@ func init() { } type ActorScript struct { - Command []string `json:"command" yaml:"command"` + Command []string `json:"command" yaml:"command"` + SkipCooldownOnError bool `json:"skip_cooldown_on_error" yaml:"skip_cooldown_on_error"` } func (a ActorScript) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData plugins.FieldCollection) (preventCooldown bool, err error) { @@ -66,7 +67,7 @@ func (a ActorScript) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eve cmd.Stdout = stdout if err := cmd.Run(); err != nil { - return false, errors.Wrap(err, "running command") + return a.SkipCooldownOnError, errors.Wrap(err, "running command") } if stdout.Len() == 0 { diff --git a/wiki/Home.md b/wiki/Home.md index 8ce20cc..085bd45 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -47,6 +47,8 @@ rules: # See below for examples # Command to execute for the chat message, must return an JSON encoded array of actions - command: [/bin/bash, -c, "echo '[{\"respond\": \"Text\"}]'"] + skip_cooldown_on_error: true # Boolean, optional, if set to true a non-zero exit-code + # will prevent the cooldown to be started for the rule # Modify an internal counter value (does NOT send a chat line) - counter: "counterid" # String to identify the counter, applies templating