diff --git a/action_respond.go b/action_respond.go index 7263ee5..0d03e8f 100644 --- a/action_respond.go +++ b/action_respond.go @@ -13,7 +13,10 @@ func init() { msg, err := formatMessage(*r.Respond, m, ruleDef, nil) if err != nil { - return errors.Wrap(err, "preparing response") + if r.RespondFallback == nil { + return errors.Wrap(err, "preparing response") + } + msg = *r.RespondFallback } return errors.Wrap( diff --git a/config.go b/config.go index cf9be25..b3f4454 100644 --- a/config.go +++ b/config.go @@ -177,13 +177,14 @@ 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"` - CounterStep *int64 `json:"counter_step" yaml:"counter_step"` - Counter *string `json:"counter" yaml:"counter"` - DeleteMessage *bool `json:"delete_message" yaml:"delete_message"` - Respond *string `json:"respond" yaml:"respond"` - Timeout *time.Duration `json:"timeout" yaml:"timeout"` + Ban *string `json:"ban" yaml:"ban"` + Command []string `json:"command" yaml:"command"` + CounterStep *int64 `json:"counter_step" yaml:"counter_step"` + Counter *string `json:"counter" yaml:"counter"` + DeleteMessage *bool `json:"delete_message" yaml:"delete_message"` + Respond *string `json:"respond" yaml:"respond"` + RespondFallback *string `json:"respond_fallback" yaml:"respond_fallback"` + Timeout *time.Duration `json:"timeout" yaml:"timeout"` } func loadConfig(filename string) error { diff --git a/wiki/Home.md b/wiki/Home.md index 7900fbd..d637e89 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -30,7 +30,8 @@ rules: # See below for examples - delete_message: true # Bool, set to true to delete # Send responding message to the channel the original message was received in - - respond: 'Hello chatter' # String, applies templating + - respond: 'Hello chatter' # String, applies templating + respond_fallback: 'Oh noes' # String, text to send if the template function causes an error (default: unset) # Issue a timeout on the user who wrote the chat-line - timeout: 1s # Duration value: 1s / 1m / 1h