Allow to skip cooldown on script error

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-09-17 14:49:56 +02:00
parent 6a154008f2
commit ac751605a8
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D
2 changed files with 5 additions and 2 deletions

View File

@ -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 {

View File

@ -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