private static FritzBot CreateFritzBot(IChatService chatService) { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <IChatService>(chatService) .AddLogging(); var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true) .AddUserSecrets("78c713a0-80e0-4e16-956a-33cf16f08a02") // Same as Fritz.StreamTools .Build(); serviceCollection.AddSingleton <IConfiguration>(config); serviceCollection.AddHttpClient("ShoutoutCommand", c => { c.BaseAddress = new Uri("https://api.twitch.tv/kraken/channels/"); c.DefaultRequestHeaders.Add("client-id", config["StreamServices:Twitch:ClientId"]); }); FritzBot.RegisterCommands(serviceCollection); var svcProvider = serviceCollection.BuildServiceProvider(); var loggerFactory = svcProvider.GetService <ILoggerFactory>() .AddConsole(LogLevel.Information); return(new FritzBot(config, svcProvider, loggerFactory)); }
public static void Execute( IServiceCollection services, IConfiguration configuration) { Configuration = configuration; services.AddSingleton <RundownRepository>(); services.Configure <FollowerGoalConfiguration>(configuration.GetSection("FollowerGoal")); services.Configure <FollowerCountConfiguration>(configuration.GetSection("FollowerCount")); services.AddStreamingServices(configuration); services.Configure <GitHubConfiguration>(configuration.GetSection("GitHub")); services.AddSingleton <FollowerClient>(); services.AddAspNetFeatures(); services.AddSingleton <IConfigureOptions <SignalrTagHelperOptions>, ConfigureSignalrTagHelperOptions>(); services.AddSingleton <SignalrTagHelperOptions>(cfg => cfg.GetService <IOptions <SignalrTagHelperOptions> >().Value); services.AddSingleton <IAttentionClient, AttentionHub>(); services.AddSingleton <IHostedService, FritzBot>(); services.AddSingleton(new GitHubClient(new ProductHeaderValue("Fritz.StreamTools"))); FritzBot.RegisterCommands(services); services.AddLazyCache(); RegisterGitHubServices(services, configuration); }
private static FritzBot CreateFritzBot(IChatService chatService) { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <IChatService>(chatService) .AddLogging(); var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true) .AddUserSecrets("78c713a0-80e0-4e16-956a-33cf16f08a02") // Same as Fritz.StreamTools .Build(); serviceCollection.AddSingleton <IConfiguration>(config); serviceCollection.AddHttpClient("ShoutoutCommand", c => { c.DefaultRequestHeaders.Add("client-id", config["StreamServices:Twitch:ClientId"]); }); FritzBot.RegisterCommands(serviceCollection); var loggerService = LoggerFactory.Create(configure => configure.AddSimpleConsole(options => { options.IncludeScopes = true; }) .SetMinimumLevel(LogLevel.Information) ); var svcProvider = serviceCollection.BuildServiceProvider(); var loggerFactory = svcProvider.GetService <ILoggerFactory>(); return(new FritzBot(config, svcProvider, loggerFactory)); }
public static void Execute(IServiceCollection services, IConfiguration configuration, Dictionary <Type, string[]> servicesRequiredConfiguration) { _Configuration = configuration; _ServicesRequiredConfiguration = servicesRequiredConfiguration; services.AddSingleton <RundownItemRepository>(); services.AddSingleton <RundownRepository>(); services.AddSingleton <IRundownService, RundownService>(); services.Configure <FollowerGoalConfiguration>(configuration.GetSection("FollowerGoal")); services.Configure <FollowerCountConfiguration>(configuration.GetSection("FollowerCount")); services.Configure <Dictionary <string, SoundFxDefinition> >(configuration.GetSection("FritzBot:SoundFxCommands")); services.Configure <GitHubConfiguration>(configuration.GetSection("GitHub")); services.AddSingleton <FollowerClient>(); services.AddAspNetFeatures(); services.AddStreamingServices(configuration); services.AddSingleton <IConfigureOptions <SignalrTagHelperOptions>, ConfigureSignalrTagHelperOptions>(); services.AddSingleton <SignalrTagHelperOptions>(cfg => cfg.GetService <IOptions <SignalrTagHelperOptions> >().Value); services.AddSingleton <IAttentionClient, AttentionHub>(); services.AddSingleton <ObsHub>(); // Add the SentimentSink //services.AddSingleton<Fritz.Chatbot.Commands.SentimentSink>(); services.AddHostedService <FritzBot>(); services.AddSingleton(new GitHubClient(new ProductHeaderValue("Fritz.StreamTools"))); FritzBot.RegisterCommands(services); services.AddLazyCache(); services.RegisterTwitchPubSub(); RegisterConfiguredServices(services, configuration); RegisterGitHubServices(services, configuration); }