hermes-client/Hermes/Socket/Requests/DeleteTTSVoiceAck.cs

41 lines
1.2 KiB
C#
Raw Permalink Normal View History

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}]");
}
}
}