mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
36 lines
626 B
Go
36 lines
626 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-irc/irc"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func init() {
|
|
registerAction(func() Actor { return &ActorBan{} })
|
|
}
|
|
|
|
type ActorBan struct {
|
|
Ban *string `json:"ban" yaml:"ban"`
|
|
}
|
|
|
|
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" }
|