mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 16:20:02 +00:00
Add fallback text for failed respond templates
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
ffe81d3358
commit
2a1b8d2a6c
3 changed files with 14 additions and 9 deletions
|
@ -13,8 +13,11 @@ func init() {
|
||||||
|
|
||||||
msg, err := formatMessage(*r.Respond, m, ruleDef, nil)
|
msg, err := formatMessage(*r.Respond, m, ruleDef, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if r.RespondFallback == nil {
|
||||||
return errors.Wrap(err, "preparing response")
|
return errors.Wrap(err, "preparing response")
|
||||||
}
|
}
|
||||||
|
msg = *r.RespondFallback
|
||||||
|
}
|
||||||
|
|
||||||
return errors.Wrap(
|
return errors.Wrap(
|
||||||
c.WriteMessage(&irc.Message{
|
c.WriteMessage(&irc.Message{
|
||||||
|
|
|
@ -183,6 +183,7 @@ type ruleAction struct {
|
||||||
Counter *string `json:"counter" yaml:"counter"`
|
Counter *string `json:"counter" yaml:"counter"`
|
||||||
DeleteMessage *bool `json:"delete_message" yaml:"delete_message"`
|
DeleteMessage *bool `json:"delete_message" yaml:"delete_message"`
|
||||||
Respond *string `json:"respond" yaml:"respond"`
|
Respond *string `json:"respond" yaml:"respond"`
|
||||||
|
RespondFallback *string `json:"respond_fallback" yaml:"respond_fallback"`
|
||||||
Timeout *time.Duration `json:"timeout" yaml:"timeout"`
|
Timeout *time.Duration `json:"timeout" yaml:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ rules: # See below for examples
|
||||||
|
|
||||||
# Send responding message to the channel the original message was received in
|
# 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
|
# Issue a timeout on the user who wrote the chat-line
|
||||||
- timeout: 1s # Duration value: 1s / 1m / 1h
|
- timeout: 1s # Duration value: 1s / 1m / 1h
|
||||||
|
|
Loading…
Reference in a new issue