twitch-bot/action_raw.go
Knut Ahlers 9c2aef9c5f
Add Whisper / RawMessage actions
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2021-05-26 15:36:03 +02:00

29 lines
558 B
Go

package main
import (
"github.com/go-irc/irc"
"github.com/pkg/errors"
)
func init() {
registerAction(func(c *irc.Client, m *irc.Message, ruleDef *rule, r *ruleAction) error {
if r.RawMessage == nil {
return nil
}
rawMsg, err := formatMessage(*r.RawMessage, m, ruleDef, nil)
if err != nil {
return errors.Wrap(err, "preparing raw message")
}
msg, err := irc.ParseMessage(rawMsg)
if err != nil {
return errors.Wrap(err, "parsing raw message")
}
return errors.Wrap(
c.WriteMessage(msg),
"sending raw message",
)
})
}