38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Text.Json;
|
|
using Serilog;
|
|
|
|
namespace TwitchChatTTS.Hermes.Socket.Requests
|
|
{
|
|
public class GetChatterIdsAck : IRequestAck
|
|
{
|
|
public string Name => "get_chatter_ids";
|
|
private readonly User _user;
|
|
private readonly JsonSerializerOptions _options;
|
|
private readonly ILogger _logger;
|
|
|
|
public GetChatterIdsAck(User user, JsonSerializerOptions options, ILogger logger)
|
|
{
|
|
_user = user;
|
|
_options = options;
|
|
_logger = logger;
|
|
}
|
|
|
|
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
|
{
|
|
var chatters = JsonSerializer.Deserialize<IEnumerable<long>>(json, _options);
|
|
if (chatters == null)
|
|
{
|
|
_logger.Warning("Chatters is null.");
|
|
return;
|
|
}
|
|
if (!chatters.Any())
|
|
{
|
|
_logger.Warning("Chatters is empty.");
|
|
return;
|
|
}
|
|
|
|
_user.Chatters = [.. chatters];
|
|
_logger.Information($"Fetched chatters [count: {chatters.Count()}]");
|
|
}
|
|
}
|
|
} |