Support sending message to different channel
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
ebde2da41d
commit
9852fc3a91
2 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
|||
package respond
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Luzifer/twitch-bot/plugins"
|
||||
"github.com/go-irc/irc"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -20,6 +23,7 @@ type actor struct {
|
|||
Respond *string `json:"respond" yaml:"respond"`
|
||||
RespondAsReply *bool `json:"respond_as_reply" yaml:"respond_as_reply"`
|
||||
RespondFallback *string `json:"respond_fallback" yaml:"respond_fallback"`
|
||||
ToChannel *string `json:"to_channel" yaml:"to_channel"`
|
||||
}
|
||||
|
||||
func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData plugins.FieldCollection) (preventCooldown bool, err error) {
|
||||
|
@ -37,10 +41,15 @@ func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData
|
|||
}
|
||||
}
|
||||
|
||||
toChannel := plugins.DeriveChannel(m, eventData)
|
||||
if a.ToChannel != nil {
|
||||
toChannel = fmt.Sprintf("#%s", strings.TrimLeft(*a.ToChannel, "#"))
|
||||
}
|
||||
|
||||
ircMessage := &irc.Message{
|
||||
Command: "PRIVMSG",
|
||||
Params: []string{
|
||||
plugins.DeriveChannel(m, eventData),
|
||||
toChannel,
|
||||
msg,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ rules: # See below for examples
|
|||
respond_as_reply: true # Boolean, optional, use Twitch-Reply feature in respond
|
||||
respond_fallback: 'Oh noes' # String, text to send if the template function causes
|
||||
# an error, applies templating (default: unset)
|
||||
to_channel: '#myotherchan' # String, channel to send the response to (default: unset)
|
||||
|
||||
# Issue a timeout on the user who wrote the chat-line
|
||||
- timeout: 1s # Duration value: 1s / 1m / 1h
|
||||
|
|
Loading…
Add table
Reference in a new issue