mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 16:50:01 +00:00
Fix: Initialize core plugins after main components are set up
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
c59ef05faa
commit
7f641ebe1e
2 changed files with 9 additions and 2 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/Luzifer/twitch-bot/internal/actors/ban"
|
"github.com/Luzifer/twitch-bot/internal/actors/ban"
|
||||||
"github.com/Luzifer/twitch-bot/internal/actors/delay"
|
"github.com/Luzifer/twitch-bot/internal/actors/delay"
|
||||||
deleteactor "github.com/Luzifer/twitch-bot/internal/actors/delete"
|
deleteactor "github.com/Luzifer/twitch-bot/internal/actors/delete"
|
||||||
|
"github.com/Luzifer/twitch-bot/internal/actors/modchannel"
|
||||||
"github.com/Luzifer/twitch-bot/internal/actors/raw"
|
"github.com/Luzifer/twitch-bot/internal/actors/raw"
|
||||||
"github.com/Luzifer/twitch-bot/internal/actors/respond"
|
"github.com/Luzifer/twitch-bot/internal/actors/respond"
|
||||||
"github.com/Luzifer/twitch-bot/internal/actors/timeout"
|
"github.com/Luzifer/twitch-bot/internal/actors/timeout"
|
||||||
|
@ -20,19 +21,21 @@ var coreActorRegistations = []plugins.RegisterFunc{
|
||||||
ban.Register,
|
ban.Register,
|
||||||
delay.Register,
|
delay.Register,
|
||||||
deleteactor.Register,
|
deleteactor.Register,
|
||||||
|
modchannel.Register,
|
||||||
raw.Register,
|
raw.Register,
|
||||||
respond.Register,
|
respond.Register,
|
||||||
timeout.Register,
|
timeout.Register,
|
||||||
whisper.Register,
|
whisper.Register,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func initCorePlugins() error {
|
||||||
args := getRegistrationArguments()
|
args := getRegistrationArguments()
|
||||||
for _, rf := range coreActorRegistations {
|
for _, rf := range coreActorRegistations {
|
||||||
if err := rf(args); err != nil {
|
if err := rf(args); err != nil {
|
||||||
log.WithError(err).Fatal("Unable to register core actor")
|
return errors.Wrap(err, "registering core plugin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerRoute(route plugins.HTTPRouteRegistrationArgs) error {
|
func registerRoute(route plugins.HTTPRouteRegistrationArgs) error {
|
||||||
|
|
4
main.go
4
main.go
|
@ -89,6 +89,10 @@ func main() {
|
||||||
router.HandleFunc("/", handleSwaggerHTML)
|
router.HandleFunc("/", handleSwaggerHTML)
|
||||||
router.HandleFunc("/openapi.json", handleSwaggerRequest)
|
router.HandleFunc("/openapi.json", handleSwaggerRequest)
|
||||||
|
|
||||||
|
if err = initCorePlugins(); err != nil {
|
||||||
|
log.WithError(err).Fatal("Unable to load core plugins")
|
||||||
|
}
|
||||||
|
|
||||||
if err = loadPlugins(cfg.PluginDir); err != nil {
|
if err = loadPlugins(cfg.PluginDir); err != nil {
|
||||||
log.WithError(err).Fatal("Unable to load plugins")
|
log.WithError(err).Fatal("Unable to load plugins")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue