2021-05-26 13:36:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-irc/irc"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-06-11 11:52:42 +00:00
|
|
|
registerAction(func() Actor { return &ActorRaw{} })
|
2021-05-26 13:36:03 +00:00
|
|
|
}
|
2021-06-11 11:52:42 +00:00
|
|
|
|
|
|
|
type ActorRaw struct {
|
|
|
|
RawMessage *string `json:"raw_message" yaml:"raw_message"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a ActorRaw) Execute(c *irc.Client, m *irc.Message, r *Rule) error {
|
|
|
|
if a.RawMessage == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
rawMsg, err := formatMessage(*a.RawMessage, m, r, 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",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a ActorRaw) IsAsync() bool { return false }
|
|
|
|
func (a ActorRaw) Name() string { return "raw" }
|