35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.Collections.Concurrent;
|
|
using System.Text.Json;
|
|
using Serilog;
|
|
|
|
namespace TwitchChatTTS.Hermes.Socket.Requests
|
|
{
|
|
public class GetTTSUsersAck : IRequestAck
|
|
{
|
|
public string Name => "get_tts_users";
|
|
private readonly User _user;
|
|
private readonly JsonSerializerOptions _options;
|
|
private readonly ILogger _logger;
|
|
|
|
public GetTTSUsersAck(User user, JsonSerializerOptions options, ILogger logger)
|
|
{
|
|
_user = user;
|
|
_options = options;
|
|
_logger = logger;
|
|
}
|
|
|
|
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
|
{
|
|
var users = JsonSerializer.Deserialize<IDictionary<long, string>>(json, _options);
|
|
if (users == null)
|
|
return;
|
|
|
|
var temp = new ConcurrentDictionary<long, string>();
|
|
foreach (var entry in users)
|
|
temp.TryAdd(entry.Key, entry.Value);
|
|
|
|
_user.VoicesSelected = temp;
|
|
_logger.Information($"Updated chatters' selected voice [count: {temp.Count()}]");
|
|
}
|
|
}
|
|
} |