private E <string> Run(bool interactive = false) { var configResult = ConfRoot.OpenOrCreate(configFilePath); if (!configResult.Ok) { return("Could not create config"); } ConfRoot config = configResult.Value; Config.Deprecated.UpgradeScript.CheckAndUpgrade(config); ConfigUpgrade2.Upgrade(config.Configs.BotsPath.Value); config.Save(); var builder = new DependencyBuilder(injector); builder.AddModule(this); builder.AddModule(config); builder.AddModule(injector); builder.AddModule(config.Db); builder.RequestModule <SystemMonitor>(); builder.RequestModule <DbStore>(); builder.AddModule(config.Plugins); builder.RequestModule <PluginManager>(); builder.AddModule(config.Web); builder.AddModule(config.Web.Interface); builder.AddModule(config.Web.Api); builder.RequestModule <WebServer>(); builder.AddModule(config.Rights); builder.RequestModule <RightsManager>(); builder.RequestModule <BotManager>(); builder.RequestModule <TokenManager>(); builder.RequestModule <CommandManager>(); builder.AddModule(config.Factories); // TODO fix interaction: rfm needs to be in the same injector as the commandsystem, otherwise duplicate error // Also TODO find solution to move commandsystem to bot, without breaking api builder.RequestModule <ResourceFactory>(); if (!builder.Build()) { Log.Error("Missing core module dependency"); return("Could not load all core modules"); } YoutubeDlHelper.DataObj = config.Tools.YoutubeDl; builder.GetModule <SystemMonitor>().StartTimedSnapshots(); builder.GetModule <CommandManager>().RegisterCollection(MainCommands.Bag); builder.GetModule <RightsManager>().CreateConfigIfNotExists(interactive); builder.GetModule <BotManager>().RunBots(interactive); builder.GetModule <WebServer>().StartWebServer(); return(R.Ok); }
private E <string> Run(ParameterData setup) { var configResult = ConfRoot.OpenOrCreate(configFilePath); if (!configResult.Ok) { return("Could not create config"); } ConfRoot config = configResult.Value; Config.Deprecated.UpgradeScript.CheckAndUpgrade(config); ConfigUpgrade2.Upgrade(config.Configs.BotsPath.Value); config.Save(); var builder = new DependencyBuilder(injector); builder.AddModule(this); builder.AddModule(config); builder.AddModule(injector); builder.AddModule(config.Db); builder.RequestModule <SystemMonitor>(); builder.RequestModule <DbStore>(); builder.AddModule(config.Plugins); builder.RequestModule <PluginManager>(); builder.AddModule(config.Web); builder.AddModule(config.Web.Interface); builder.AddModule(config.Web.Api); builder.RequestModule <WebServer>(); builder.AddModule(config.Rights); builder.RequestModule <RightsManager>(); builder.RequestModule <BotManager>(); builder.RequestModule <TokenManager>(); builder.RequestModule <CommandManager>(); builder.AddModule(config.Factories); builder.RequestModule <SpotifyApi>(); builder.RequestModule <ResourceResolver>(); builder.RequestModule <Stats>(); builder.AddModule(config.Tools.Librespot); if (!builder.Build()) { Log.Error("Missing core module dependency"); return("Could not load all core modules"); } YoutubeDlHelper.DataObj = config.Tools.YoutubeDl; builder.GetModule <SystemMonitor>().StartTimedSnapshots(); builder.GetModule <CommandManager>().RegisterCollection(MainCommands.Bag); builder.GetModule <RightsManager>().CreateConfigIfNotExists(setup.Interactive); builder.GetModule <BotManager>().RunBots(setup.Interactive); builder.GetModule <WebServer>().StartWebServer(); builder.GetModule <Stats>().StartTimer(setup.SendStats); return(R.Ok); }