twitch-bot/action_ban.go

37 lines
626 B
Go
Raw Normal View History

2020-12-21 00:32:39 +00:00
package main
import (
"fmt"
"github.com/go-irc/irc"
"github.com/pkg/errors"
)
func init() {
registerAction(func() Actor { return &ActorBan{} })
}
2020-12-21 00:32:39 +00:00
type ActorBan struct {
Ban *string `json:"ban" yaml:"ban"`
2020-12-21 00:32:39 +00:00
}
func (a ActorBan) Execute(c *irc.Client, m *irc.Message, r *Rule) error {
if a.Ban == nil {
return nil
}
return errors.Wrap(
c.WriteMessage(&irc.Message{
Command: "PRIVMSG",
Params: []string{
m.Params[0],
fmt.Sprintf("/ban %s %s", m.User, *a.Ban),
},
}),
"sending timeout",
)
}
func (a ActorBan) IsAsync() bool { return false }
func (a ActorBan) Name() string { return "ban" }