Cleaned up request acks. Added internal service bus for internal messaging.
This commit is contained in:
47
Hermes/Socket/Requests/UpdateTTSVoiceAck.cs
Normal file
47
Hermes/Socket/Requests/UpdateTTSVoiceAck.cs
Normal 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}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user