using TwitchChatTTS.OBS.Socket.Manager; using TwitchChatTTS.OBS.Socket; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.DependencyInjection; using TwitchChatTTS; using CommonSocketLibrary.Abstract; using CommonSocketLibrary.Common; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; using TwitchChatTTS.Seven.Socket; using TwitchChatTTS.OBS.Socket.Handlers; using TwitchChatTTS.Seven.Socket.Handlers; using TwitchChatTTS.Seven.Socket.Managers; using TwitchChatTTS.Hermes.Socket.Handlers; using TwitchChatTTS.Hermes.Socket; using TwitchChatTTS.Hermes.Socket.Managers; using TwitchChatTTS.Chat.Commands; using System.Text.Json; using Serilog; using Serilog.Events; using Serilog.Sinks.SystemConsole.Themes; using TwitchChatTTS.Twitch.Redemptions; using TwitchChatTTS.Chat.Groups.Permissions; using TwitchChatTTS.Chat.Groups; using TwitchChatTTS.Chat.Emotes; using HermesSocketLibrary.Requests.Callbacks; using static TwitchChatTTS.Chat.Commands.TTSCommands; using TwitchChatTTS.Twitch.Socket; using TwitchChatTTS.Twitch.Socket.Messages; using TwitchChatTTS.Twitch.Socket.Handlers; using CommonSocketLibrary.Backoff; // dotnet publish -r linux-x64 -p:PublishSingleFile=true --self-contained true // dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained true // SE voices: https://api.streamelements.com/kappa/v2/speech?voice=brian&text=hello HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); var s = builder.Services; var deserializer = new DeserializerBuilder() .IgnoreUnmatchedProperties() .WithNamingConvention(HyphenatedNamingConvention.Instance) .Build(); var configContent = File.ReadAllText("tts.config.yml"); var configuration = deserializer.Deserialize(configContent); s.AddSingleton(configuration); var logger = new LoggerConfiguration() .MinimumLevel.Verbose() .MinimumLevel.Override("mariuszgromada", LogEventLevel.Error) .Enrich.FromLogContext() .WriteTo.File("logs/log-.log", restrictedToMinimumLevel: LogEventLevel.Debug, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 3) .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Information, theme: SystemConsoleTheme.Colored) .CreateLogger(); s.AddSerilog(logger); s.AddSingleton(); s.AddSingleton(); s.AddSingleton, CallbackManager>(); s.AddSingleton(new JsonSerializerOptions() { PropertyNameCaseInsensitive = false, PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower }); // Command parameters s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); s.AddSingleton(); // OBS websocket s.AddKeyedSingleton("obs"); s.AddKeyedSingleton("obs"); s.AddKeyedSingleton("obs"); s.AddKeyedSingleton("obs"); s.AddKeyedSingleton("obs"); s.AddKeyedSingleton, OBSMessageTypeManager>("obs"); s.AddKeyedSingleton, OBSSocketClient>("obs"); // 7tv websocket s.AddKeyedSingleton("7tv"); s.AddKeyedSingleton("7tv"); s.AddKeyedSingleton("7tv"); s.AddKeyedSingleton("7tv"); s.AddKeyedSingleton("7tv"); s.AddKeyedSingleton, SevenMessageTypeManager>("7tv"); s.AddKeyedSingleton, SevenSocketClient>("7tv"); // twitch websocket s.AddKeyedSingleton("twitch", new ExponentialBackoff(1000, 120 * 1000)); s.AddSingleton(); s.AddKeyedTransient, TwitchWebsocketClient>("twitch", (sp, _) => { var factory = sp.GetRequiredService(); var client = factory.GetWorkingClient(); client.Connect().Wait(); return client; }); s.AddKeyedTransient, TwitchWebsocketClient>("twitch-create"); s.AddKeyedSingleton("twitch"); s.AddKeyedSingleton("twitch"); s.AddKeyedSingleton("twitch"); s.AddKeyedSingleton("twitch"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); s.AddKeyedSingleton("twitch-notifications"); // hermes websocket s.AddKeyedSingleton("hermes"); s.AddKeyedSingleton("hermes"); s.AddKeyedSingleton("hermes"); s.AddKeyedSingleton, HermesMessageTypeManager>("hermes"); s.AddKeyedSingleton, HermesSocketClient>("hermes"); s.AddHostedService(); using IHost host = builder.Build(); await host.RunAsync();