mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-12 18:12:41 +00:00
29 lines
558 B
Go
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",
|
|
)
|
|
})
|
|
}
|