From 44673eadd2a6a23de08d056fe173adebbd56f0dc Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 10 Sep 2021 17:57:04 +0200 Subject: [PATCH] Expose TwitchClient to plugins Signed-off-by: Knut Ahlers --- action_core.go | 2 ++ plugins/interface.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/action_core.go b/action_core.go index 610e596..db2eb10 100644 --- a/action_core.go +++ b/action_core.go @@ -11,6 +11,7 @@ import ( "github.com/Luzifer/twitch-bot/internal/actors/timeout" "github.com/Luzifer/twitch-bot/internal/actors/whisper" "github.com/Luzifer/twitch-bot/plugins" + "github.com/Luzifer/twitch-bot/twitch" "github.com/pkg/errors" log "github.com/sirupsen/logrus" ) @@ -59,6 +60,7 @@ func getRegistrationArguments() plugins.RegistrationArguments { return plugins.RegistrationArguments{ FormatMessage: formatMessage, GetLogger: func(moduleName string) *log.Entry { return log.WithField("module", moduleName) }, + GetTwitchClient: func() *twitch.Client { return twitchClient }, RegisterActor: registerAction, RegisterAPIRoute: registerRoute, RegisterCron: cronService.AddFunc, diff --git a/plugins/interface.go b/plugins/interface.go index de80fd8..8cda6ed 100644 --- a/plugins/interface.go +++ b/plugins/interface.go @@ -1,6 +1,7 @@ package plugins import ( + "github.com/Luzifer/twitch-bot/twitch" "github.com/go-irc/irc" "github.com/robfig/cron/v3" log "github.com/sirupsen/logrus" @@ -40,6 +41,8 @@ type ( FormatMessage MsgFormatter // GetLogger returns a sirupsen log.Entry pre-configured with the module name GetLogger LoggerCreationFunc + // GetTwitchClient retrieves a fully configured Twitch client with initialized cache + GetTwitchClient func() *twitch.Client // RegisterActor is used to register a new IRC rule-actor implementing the Actor interface RegisterActor ActorRegistrationFunc // RegisterAPIRoute registers a new HTTP handler function including documentation