mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-14 02:52:42 +00:00
30 lines
558 B
Go
30 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",
|
||
|
)
|
||
|
})
|
||
|
}
|