Plugins, Bugfixes & Cleanup

This commit is contained in:
2023-03-31 20:21:49 +00:00
parent 3d15d09dd7
commit 6e5450aa80
10 changed files with 113 additions and 59 deletions

18
main.go
View File

@@ -14,6 +14,8 @@ import (
"github.com/yeslayla/birdbot/events"
)
const PluginsDirectory = "./plugins"
func main() {
configDir, _ := os.UserConfigDir()
@@ -56,16 +58,24 @@ func main() {
loader := app.NewComponentLoader(bot)
if cfg.Features.AnnounceEvents {
if cfg.Features.AnnounceEvents.IsEnabledByDefault() {
loader.LoadComponent(events.NewAnnounceEventsComponent(bot.Mastodon, cfg.Discord.NotificationChannel))
}
if cfg.Features.ManageEventChannels {
loader.LoadComponent(events.NewManageEventChannelsComponent(cfg.Discord.EventCategory, bot.Session))
if cfg.Features.ManageEventChannels.IsEnabledByDefault() {
loader.LoadComponent(events.NewManageEventChannelsComponent(cfg.Discord.EventCategory, cfg.Discord.ArchiveCategory, bot.Session))
}
if cfg.Features.ReccurringEvents {
if cfg.Features.ReccurringEvents.IsEnabledByDefault() {
loader.LoadComponent(events.NewRecurringEventsComponent())
}
if _, err := os.Stat(PluginsDirectory); !os.IsNotExist(err) {
pluginLoader := app.NewPluginLoader()
components := pluginLoader.LoadPlugins(PluginsDirectory)
for _, comp := range components {
loader.LoadComponent(comp)
}
}
if err := bot.Run(); err != nil {
log.Fatal(err)
}