2021-08-19 13:33:56 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/go-irc/irc"
|
|
|
|
"github.com/pkg/errors"
|
2021-11-25 22:48:16 +00:00
|
|
|
|
|
|
|
"github.com/Luzifer/twitch-bot/plugins"
|
2021-08-19 13:33:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ plugins.RegisterFunc = Register
|
|
|
|
|
|
|
|
func Register(args plugins.RegistrationArguments) error {
|
|
|
|
args.GetLogger("plugin-example").Warn("Example Register called")
|
|
|
|
|
|
|
|
args.RegisterActor(func() plugins.Actor { return &actor{} })
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type actor struct {
|
|
|
|
Example bool `json:"example" yaml:"example"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule) (preventCooldown bool, err error) {
|
|
|
|
if !a.Example {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, errors.Wrap(
|
|
|
|
c.WriteMessage(&irc.Message{
|
|
|
|
Command: "PRIVMSG",
|
|
|
|
Params: []string{
|
|
|
|
m.Params[0],
|
|
|
|
fmt.Sprintf("@%s Example plugin noticed you! KonCha", m.User),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
"sending response",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a actor) IsAsync() bool { return false }
|
|
|
|
func (a actor) Name() string { return "example" }
|