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
|
package respond
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Luzifer/twitch-bot/plugins"
|
"github.com/Luzifer/twitch-bot/plugins"
|
||||||
"github.com/go-irc/irc"
|
"github.com/go-irc/irc"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -20,6 +23,7 @@ type actor struct {
|
||||||
Respond *string `json:"respond" yaml:"respond"`
|
Respond *string `json:"respond" yaml:"respond"`
|
||||||
RespondAsReply *bool `json:"respond_as_reply" yaml:"respond_as_reply"`
|
RespondAsReply *bool `json:"respond_as_reply" yaml:"respond_as_reply"`
|
||||||
RespondFallback *string `json:"respond_fallback" yaml:"respond_fallback"`
|
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) {
|
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{
|
ircMessage := &irc.Message{
|
||||||
Command: "PRIVMSG",
|
Command: "PRIVMSG",
|
||||||
Params: []string{
|
Params: []string{
|
||||||
plugins.DeriveChannel(m, eventData),
|
toChannel,
|
||||||
msg,
|
msg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ rules: # See below for examples
|
||||||
respond_as_reply: true # Boolean, optional, use Twitch-Reply feature in respond
|
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
|
respond_fallback: 'Oh noes' # String, text to send if the template function causes
|
||||||
# an error, applies templating (default: unset)
|
# 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
|
# 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…
Add table
Add a link
Reference in a new issue