Cleaned up request acks. Added internal service bus for internal messaging.
This commit is contained in:
38
Hermes/Socket/Requests/GetChatterIdsAck.cs
Normal file
38
Hermes/Socket/Requests/GetChatterIdsAck.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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()}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user