Cleaned up request acks. Added internal service bus for internal messaging.
This commit is contained in:
41
Hermes/Socket/Requests/DeleteTTSVoiceAck.cs
Normal file
41
Hermes/Socket/Requests/DeleteTTSVoiceAck.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Serilog;
|
||||
|
||||
namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
{
|
||||
public class DeleteTTSVoiceAck : IRequestAck
|
||||
{
|
||||
public string Name => "delete_tts_voice";
|
||||
private readonly User _user;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DeleteTTSVoiceAck(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();
|
||||
if (string.IsNullOrEmpty(voice))
|
||||
{
|
||||
_logger.Warning($"Voice Id is invalid [voice id: {voice}]");
|
||||
return;
|
||||
}
|
||||
if (!_user.VoicesAvailable.TryGetValue(voice, out string? voiceName))
|
||||
{
|
||||
_logger.Warning($"Voice Id does not exist [voice id: {voice}]");
|
||||
return;
|
||||
}
|
||||
|
||||
_user.VoicesAvailable.Remove(voice);
|
||||
_logger.Information($"Deleted a voice [voice id: {voice}][voice name: {voiceName}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user