Cleaned up request acks. Added internal service bus for internal messaging.

This commit is contained in:
Tom
2024-11-08 15:32:42 +00:00
parent fe2eb86a08
commit 66f2bf7ec6
33 changed files with 1326 additions and 415 deletions

View File

@@ -0,0 +1,47 @@
using Serilog;
namespace TwitchChatTTS.Hermes.Socket.Requests
{
public class UpdateTTSVoiceAck : IRequestAck
{
public string Name => "update_tts_voice";
private readonly User _user;
private readonly ILogger _logger;
public UpdateTTSVoiceAck(User user, ILogger logger)
{
_user = user;
_logger = logger;
}
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
{
if (requestData == null)
{
_logger.Warning("Request data is null.");
return;
}
var voice = requestData["voice"].ToString();
var voiceId = requestData["idd"].ToString();
if (string.IsNullOrEmpty(voice))
{
_logger.Warning("Voice name is invalid.");
return;
}
if (string.IsNullOrEmpty(voiceId))
{
_logger.Warning("Voice Id is invalid.");
return;
}
if (_user.VoicesAvailable.ContainsKey(voiceId))
{
_logger.Warning($"Voice Id already exists [voice id: {voiceId}]");
return;
}
_user.VoicesAvailable[voiceId] = voice;
_logger.Information($"Created a new tts voice [voice id: {voiceId}][voice name: {voice}]");
}
}
}