2021-08-19 13:33:56 +00:00
|
|
|
package ban
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/Luzifer/twitch-bot/plugins"
|
|
|
|
"github.com/go-irc/irc"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Register(args plugins.RegistrationArguments) error {
|
|
|
|
args.RegisterActor(func() plugins.Actor { return &actor{} })
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type actor struct {
|
|
|
|
Ban *string `json:"ban" yaml:"ban"`
|
|
|
|
}
|
|
|
|
|
2021-09-02 21:26:39 +00:00
|
|
|
func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData plugins.FieldCollection) (preventCooldown bool, err error) {
|
2021-08-19 13:33:56 +00:00
|
|
|
if a.Ban == nil {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, errors.Wrap(
|
|
|
|
c.WriteMessage(&irc.Message{
|
|
|
|
Command: "PRIVMSG",
|
|
|
|
Params: []string{
|
2021-09-02 21:26:39 +00:00
|
|
|
plugins.DeriveChannel(m, eventData),
|
|
|
|
fmt.Sprintf("/ban %s %s", plugins.DeriveUser(m, eventData), *a.Ban),
|
2021-08-19 13:33:56 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
"sending timeout",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a actor) IsAsync() bool { return false }
|
|
|
|
func (a actor) Name() string { return "ban" }
|