2020-12-21 00:32:39 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/go-irc/irc"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-06-11 11:52:42 +00:00
|
|
|
registerAction(func() Actor { return &ActorBan{} })
|
|
|
|
}
|
2020-12-21 00:32:39 +00:00
|
|
|
|
2021-06-11 11:52:42 +00:00
|
|
|
type ActorBan struct {
|
|
|
|
Ban *string `json:"ban" yaml:"ban"`
|
2020-12-21 00:32:39 +00:00
|
|
|
}
|
2021-06-11 11:52:42 +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" }
|