2021-08-19 13:33:56 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-08-25 18:53:04 +00:00
|
|
|
"fmt"
|
|
|
|
|
2021-08-19 13:33:56 +00:00
|
|
|
"github.com/Luzifer/twitch-bot/internal/actors/ban"
|
|
|
|
"github.com/Luzifer/twitch-bot/internal/actors/delay"
|
|
|
|
deleteactor "github.com/Luzifer/twitch-bot/internal/actors/delete"
|
|
|
|
"github.com/Luzifer/twitch-bot/internal/actors/raw"
|
|
|
|
"github.com/Luzifer/twitch-bot/internal/actors/respond"
|
|
|
|
"github.com/Luzifer/twitch-bot/internal/actors/timeout"
|
|
|
|
"github.com/Luzifer/twitch-bot/internal/actors/whisper"
|
|
|
|
"github.com/Luzifer/twitch-bot/plugins"
|
2021-08-25 18:53:04 +00:00
|
|
|
"github.com/gorilla/mux"
|
2021-08-19 13:33:56 +00:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var coreActorRegistations = []plugins.RegisterFunc{
|
|
|
|
ban.Register,
|
|
|
|
delay.Register,
|
|
|
|
deleteactor.Register,
|
|
|
|
raw.Register,
|
|
|
|
respond.Register,
|
|
|
|
timeout.Register,
|
|
|
|
whisper.Register,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
args := getRegistrationArguments()
|
|
|
|
for _, rf := range coreActorRegistations {
|
|
|
|
if err := rf(args); err != nil {
|
|
|
|
log.WithError(err).Fatal("Unable to register core actor")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getRegistrationArguments() plugins.RegistrationArguments {
|
|
|
|
return plugins.RegistrationArguments{
|
2021-08-19 14:40:34 +00:00
|
|
|
FormatMessage: formatMessage,
|
2021-08-25 18:53:04 +00:00
|
|
|
GetHTTPRouter: func(name string) *mux.Router { return router.PathPrefix(fmt.Sprintf("/%s/", name)).Subrouter() },
|
2021-08-19 14:40:34 +00:00
|
|
|
GetLogger: func(moduleName string) *log.Entry { return log.WithField("module", moduleName) },
|
|
|
|
RegisterActor: registerAction,
|
2021-08-24 22:44:49 +00:00
|
|
|
RegisterCron: cronService.AddFunc,
|
2021-08-19 14:40:34 +00:00
|
|
|
RegisterTemplateFunction: tplFuncs.Register,
|
|
|
|
SendMessage: sendMessage,
|
2021-08-19 13:33:56 +00:00
|
|
|
}
|
|
|
|
}
|