mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-21 04:11:16 +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",
|
||
|
)
|
||
|
})
|
||
|
}
|