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

37 lines
1.1 KiB
C#
Raw Permalink Normal View History

using Serilog;
namespace TwitchChatTTS.Hermes.Socket.Requests
{
public class UpdateDefaultTTSVoiceAck : IRequestAck
{
public string Name => "update_default_tts_voice";
private readonly User _user;
private readonly ILogger _logger;
public UpdateDefaultTTSVoiceAck(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;
}
if (requestData.TryGetValue("voice", out object? voice) == true && voice is string v)
{
if (_user.VoicesEnabled.Contains(v))
{
_user.DefaultTTSVoice = v;
_logger.Information($"Default TTS voice was changed to '{v}'.");
return;
}
}
_logger.Warning("Failed to update default TTS voice via request.");
}
}
}