2024-03-12 14:05:27 -04:00
|
|
|
|
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;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
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;
|
2024-06-16 20:19:31 -04:00
|
|
|
|
using Serilog;
|
|
|
|
|
using Serilog.Events;
|
2024-06-24 18:11:36 -04:00
|
|
|
|
using Serilog.Sinks.SystemConsole.Themes;
|
|
|
|
|
using TwitchChatTTS.Twitch.Redemptions;
|
2024-07-12 13:36:09 -04:00
|
|
|
|
using TwitchChatTTS.Chat.Groups.Permissions;
|
|
|
|
|
using TwitchChatTTS.Chat.Groups;
|
2024-07-16 00:48:55 -04:00
|
|
|
|
using TwitchChatTTS.Chat.Emotes;
|
|
|
|
|
using HermesSocketLibrary.Requests.Callbacks;
|
2024-07-19 12:56:41 -04:00
|
|
|
|
using static TwitchChatTTS.Chat.Commands.TTSCommands;
|
2024-08-04 19:46:10 -04:00
|
|
|
|
using TwitchChatTTS.Twitch.Socket;
|
|
|
|
|
using TwitchChatTTS.Twitch.Socket.Messages;
|
|
|
|
|
using TwitchChatTTS.Twitch.Socket.Handlers;
|
2024-08-06 15:29:29 -04:00
|
|
|
|
using CommonSocketLibrary.Backoff;
|
2024-08-12 12:42:53 -04:00
|
|
|
|
using TwitchChatTTS.Chat.Speech;
|
2024-08-12 01:44:31 -04:00
|
|
|
|
using TwitchChatTTS.Chat.Messaging;
|
2024-08-12 13:49:36 -04:00
|
|
|
|
using TwitchChatTTS.Chat.Observers;
|
2024-08-14 14:19:18 -04:00
|
|
|
|
using TwitchChatTTS.Chat.Commands.Limits;
|
2024-11-08 10:32:42 -05:00
|
|
|
|
using TwitchChatTTS.Hermes.Socket.Requests;
|
|
|
|
|
using TwitchChatTTS.Bus;
|
2024-12-02 15:51:04 -05:00
|
|
|
|
using TwitchChatTTS.Veadotube;
|
2024-12-02 21:39:27 -05:00
|
|
|
|
using TwitchChatTTS.Veadotube.Handlers;
|
2024-03-12 14:05:27 -04:00
|
|
|
|
|
|
|
|
|
// 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()
|
2024-06-24 18:11:36 -04:00
|
|
|
|
.IgnoreUnmatchedProperties()
|
2024-03-12 14:05:27 -04:00
|
|
|
|
.WithNamingConvention(HyphenatedNamingConvention.Instance)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var configContent = File.ReadAllText("tts.config.yml");
|
|
|
|
|
var configuration = deserializer.Deserialize<Configuration>(configContent);
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddSingleton(configuration);
|
2024-03-12 14:05:27 -04:00
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
|
var logger = new LoggerConfiguration()
|
2024-06-24 18:11:36 -04:00
|
|
|
|
.MinimumLevel.Verbose()
|
|
|
|
|
.MinimumLevel.Override("mariuszgromada", LogEventLevel.Error)
|
|
|
|
|
.Enrich.FromLogContext()
|
2024-07-12 13:36:09 -04:00
|
|
|
|
.WriteTo.File("logs/log-.log", restrictedToMinimumLevel: LogEventLevel.Debug, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 3)
|
2024-06-24 18:11:36 -04:00
|
|
|
|
.WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Information, theme: SystemConsoleTheme.Colored)
|
2024-06-16 20:19:31 -04:00
|
|
|
|
.CreateLogger();
|
|
|
|
|
|
|
|
|
|
s.AddSerilog(logger);
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddSingleton<User>();
|
2024-08-04 19:46:10 -04:00
|
|
|
|
s.AddSingleton<AudioPlaybackEngine>();
|
2024-07-16 00:48:55 -04:00
|
|
|
|
s.AddSingleton<ICallbackManager<HermesRequestData>, CallbackManager<HermesRequestData>>();
|
2024-03-12 14:05:27 -04:00
|
|
|
|
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddSingleton(new JsonSerializerOptions()
|
2024-06-16 20:19:31 -04:00
|
|
|
|
{
|
2024-03-15 08:27:35 -04:00
|
|
|
|
PropertyNameCaseInsensitive = false,
|
|
|
|
|
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
|
2024-03-12 14:05:27 -04:00
|
|
|
|
});
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
|
|
|
|
// Command parameters
|
2024-07-19 12:56:41 -04:00
|
|
|
|
s.AddSingleton<IChatCommand, SkipCommand>();
|
|
|
|
|
s.AddSingleton<IChatCommand, VoiceCommand>();
|
|
|
|
|
s.AddSingleton<IChatCommand, RefreshCommand>();
|
2024-08-11 17:22:37 -04:00
|
|
|
|
s.AddSingleton<IChatCommand, NightbotCommand>();
|
2024-07-19 12:56:41 -04:00
|
|
|
|
s.AddSingleton<IChatCommand, OBSCommand>();
|
|
|
|
|
s.AddSingleton<IChatCommand, TTSCommand>();
|
|
|
|
|
s.AddSingleton<IChatCommand, VersionCommand>();
|
|
|
|
|
s.AddSingleton<ICommandBuilder, CommandBuilder>();
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddSingleton<ICommandManager, CommandManager>();
|
2024-10-22 03:54:59 -04:00
|
|
|
|
s.AddTransient<ICommandFactory, CommandFactory>();
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
2024-11-08 10:32:42 -05:00
|
|
|
|
// Request acks
|
|
|
|
|
s.AddSingleton<RequestAckManager>();
|
|
|
|
|
s.AddTransient<IRequestAck, CreatePolicyAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, CreateTTSUserAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, CreateTTSVoiceAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, DeletePolicyAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, DeleteTTSVoiceAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetChatterIdsAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetConnectionsAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetDefaultTTSVoiceAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetEmotesAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetEnabledTTSVoicesAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetPermissionsAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetPoliciesAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetRedeemableActionsAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetRedemptionsAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetTTSUsersAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetTTSVoicesAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, GetTTSWordFiltersAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, UpdateDefaultTTSVoiceAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, UpdatePolicyAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, UpdateTTSUserAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, UpdateTTSVoiceAck>();
|
|
|
|
|
s.AddTransient<IRequestAck, UpdateTTSVoiceStateAck>();
|
|
|
|
|
|
2024-03-12 14:05:27 -04:00
|
|
|
|
s.AddSingleton<TTSPlayer>();
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddSingleton<IRedemptionManager, RedemptionManager>();
|
2024-06-16 20:19:31 -04:00
|
|
|
|
s.AddSingleton<HermesApiClient>();
|
2024-03-12 14:05:27 -04:00
|
|
|
|
s.AddSingleton<TwitchApiClient>();
|
|
|
|
|
|
|
|
|
|
s.AddSingleton<SevenApiClient>();
|
2024-07-16 00:48:55 -04:00
|
|
|
|
s.AddSingleton<IEmoteDatabase, EmoteDatabase>();
|
2024-03-12 14:05:27 -04:00
|
|
|
|
|
2024-11-08 10:32:42 -05:00
|
|
|
|
s.AddSingleton<ServiceBusCentral>();
|
|
|
|
|
|
2024-08-12 13:49:36 -04:00
|
|
|
|
s.AddSingleton<TTSConsumer>();
|
|
|
|
|
s.AddSingleton<TTSPublisher>();
|
|
|
|
|
|
2024-10-22 03:54:59 -04:00
|
|
|
|
s.AddSingleton<IChatMessageReader, ChatMessageReader>();
|
|
|
|
|
s.AddSingleton<IUsagePolicy<long>, UsagePolicy<long>>();
|
2024-11-08 10:32:42 -05:00
|
|
|
|
s.AddSingleton<IChatterGroupManager, ChatterGroupManager>();
|
|
|
|
|
s.AddSingleton<IGroupPermissionManager, GroupPermissionManager>();
|
2024-08-14 14:19:18 -04:00
|
|
|
|
|
2024-03-12 14:05:27 -04:00
|
|
|
|
// OBS websocket
|
2024-07-19 12:56:41 -04:00
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, HelloHandler>("obs");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, IdentifiedHandler>("obs");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, RequestResponseHandler>("obs");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, RequestBatchResponseHandler>("obs");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, EventMessageHandler>("obs");
|
|
|
|
|
|
|
|
|
|
s.AddKeyedSingleton<MessageTypeManager<IWebSocketHandler>, OBSMessageTypeManager>("obs");
|
2024-03-12 14:05:27 -04:00
|
|
|
|
s.AddKeyedSingleton<SocketClient<WebSocketMessage>, OBSSocketClient>("obs");
|
|
|
|
|
|
|
|
|
|
// 7tv websocket
|
2024-08-11 17:41:22 -04:00
|
|
|
|
s.AddKeyedSingleton<IBackoff>("7tv", new ExponentialBackoff(1000, 30 * 1000));
|
2024-07-19 12:56:41 -04:00
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, SevenHelloHandler>("7tv");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, DispatchHandler>("7tv");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, ReconnectHandler>("7tv");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, ErrorHandler>("7tv");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, EndOfStreamHandler>("7tv");
|
|
|
|
|
|
|
|
|
|
s.AddKeyedSingleton<MessageTypeManager<IWebSocketHandler>, SevenMessageTypeManager>("7tv");
|
2024-03-12 14:05:27 -04:00
|
|
|
|
s.AddKeyedSingleton<SocketClient<WebSocketMessage>, SevenSocketClient>("7tv");
|
|
|
|
|
|
2024-12-02 15:51:04 -05:00
|
|
|
|
// Veadotube
|
2024-12-02 21:39:27 -05:00
|
|
|
|
s.AddKeyedSingleton<IVeadotubeMessageHandler, FetchStatesHandler>("veadotube");
|
|
|
|
|
|
2024-12-02 15:51:04 -05:00
|
|
|
|
s.AddKeyedSingleton<MessageTypeManager<IWebSocketHandler>, VeadoMessageTypeManager>("veadotube");
|
|
|
|
|
s.AddKeyedSingleton<SocketClient<object>, VeadoSocketClient>("veadotube");
|
|
|
|
|
|
2024-08-11 17:22:37 -04:00
|
|
|
|
// Nightbot
|
|
|
|
|
s.AddSingleton<NightbotApiClient>();
|
|
|
|
|
|
2024-08-04 19:46:10 -04:00
|
|
|
|
// twitch websocket
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddKeyedSingleton<IBackoff>("twitch", new ExponentialBackoff(1000, 120 * 1000));
|
|
|
|
|
s.AddSingleton<ITwitchConnectionManager, TwitchConnectionManager>();
|
|
|
|
|
s.AddKeyedTransient<SocketClient<TwitchWebsocketMessage>, TwitchWebsocketClient>("twitch", (sp, _) =>
|
|
|
|
|
{
|
|
|
|
|
var factory = sp.GetRequiredService<ITwitchConnectionManager>();
|
|
|
|
|
var client = factory.GetWorkingClient();
|
|
|
|
|
client.Connect().Wait();
|
|
|
|
|
return client;
|
|
|
|
|
});
|
|
|
|
|
s.AddKeyedTransient<SocketClient<TwitchWebsocketMessage>, TwitchWebsocketClient>("twitch-create");
|
2024-08-04 19:46:10 -04:00
|
|
|
|
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, SessionKeepAliveHandler>("twitch");
|
2024-08-04 19:46:10 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, SessionWelcomeHandler>("twitch");
|
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, SessionReconnectHandler>("twitch");
|
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, NotificationHandler>("twitch");
|
|
|
|
|
|
2024-10-22 03:54:59 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelAdBreakBeginHandler>("twitch-notifications");
|
2024-08-04 19:46:10 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelBanHandler>("twitch-notifications");
|
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelChatMessageHandler>("twitch-notifications");
|
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelChatClearHandler>("twitch-notifications");
|
2024-08-07 18:01:04 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelChatClearUserHandler>("twitch-notifications");
|
2024-08-04 19:46:10 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelChatDeleteMessageHandler>("twitch-notifications");
|
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelCustomRedemptionHandler>("twitch-notifications");
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelFollowHandler>("twitch-notifications");
|
2024-08-07 18:01:04 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelRaidHandler>("twitch-notifications");
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelResubscriptionHandler>("twitch-notifications");
|
2024-08-04 19:46:10 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelSubscriptionHandler>("twitch-notifications");
|
2024-08-06 15:29:29 -04:00
|
|
|
|
s.AddKeyedSingleton<ITwitchSocketHandler, ChannelSubscriptionGiftHandler>("twitch-notifications");
|
2024-08-04 19:46:10 -04:00
|
|
|
|
|
2024-03-15 08:27:35 -04:00
|
|
|
|
// hermes websocket
|
2024-08-11 17:41:22 -04:00
|
|
|
|
s.AddKeyedSingleton<IBackoff>("hermes", new ExponentialBackoff(1000, 15 * 1000));
|
2024-07-19 12:56:41 -04:00
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, HeartbeatHandler>("hermes");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, LoginAckHandler>("hermes");
|
|
|
|
|
s.AddKeyedSingleton<IWebSocketHandler, RequestAckHandler>("hermes");
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
2024-07-19 12:56:41 -04:00
|
|
|
|
s.AddKeyedSingleton<MessageTypeManager<IWebSocketHandler>, HermesMessageTypeManager>("hermes");
|
2024-03-15 08:27:35 -04:00
|
|
|
|
s.AddKeyedSingleton<SocketClient<WebSocketMessage>, HermesSocketClient>("hermes");
|
|
|
|
|
|
2024-08-12 13:49:36 -04:00
|
|
|
|
s.AddSingleton<TTSEngine>();
|
|
|
|
|
|
2024-08-12 12:42:53 -04:00
|
|
|
|
s.AddHostedService<TTSListening>();
|
2024-08-12 13:49:36 -04:00
|
|
|
|
s.AddHostedService<TTSEngine>(p => p.GetRequiredService<TTSEngine>());
|
|
|
|
|
s.AddHostedService<TTS>();
|
2024-03-12 14:05:27 -04:00
|
|
|
|
using IHost host = builder.Build();
|
|
|
|
|
await host.RunAsync();
|