Added Actions & Redemptions updates via websocket messages. Updated RedemptionManager due to live changes.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using HermesSocketServer.Models;
|
||||
using HermesSocketServer.Messages;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Chat.Commands.Limits;
|
||||
using TwitchChatTTS.Chat.Groups;
|
||||
@ -24,7 +24,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
|
||||
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
||||
{
|
||||
var policy = JsonSerializer.Deserialize<PolicyMessage>(json, _options);
|
||||
var policy = JsonSerializer.Deserialize<Policy>(json, _options);
|
||||
if (policy == null)
|
||||
{
|
||||
_logger.Warning($"Policy data failed: null");
|
||||
@ -40,7 +40,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
|
||||
_logger.Debug($"Policy data [policy id: {policy.Id}][path: {policy.Path}][group id: {policy.GroupId}][group name: {group.Name}]");
|
||||
_policies.Set(group.Name, policy.Path, policy.Usage, TimeSpan.FromMilliseconds(policy.Span));
|
||||
_logger.Information($"Policy has been updated [policy id: {policy.Id}]");
|
||||
_logger.Information($"Policy has been created [policy id: {policy.Id}]");
|
||||
}
|
||||
}
|
||||
}
|
35
Hermes/Socket/Requests/CreateRedeemableActionAck.cs
Normal file
35
Hermes/Socket/Requests/CreateRedeemableActionAck.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Text.Json;
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Twitch.Redemptions;
|
||||
|
||||
namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
{
|
||||
public class CreateRedeemableActionAck : IRequestAck
|
||||
{
|
||||
public string Name => "create_redeemable_action";
|
||||
private readonly IRedemptionManager _redemptions;
|
||||
private readonly JsonSerializerOptions _options;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public CreateRedeemableActionAck(IRedemptionManager redemptions, JsonSerializerOptions options, ILogger logger)
|
||||
{
|
||||
_redemptions = redemptions;
|
||||
_options = options;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
||||
{
|
||||
var action = JsonSerializer.Deserialize<RedeemableAction>(json, _options);
|
||||
if (action == null)
|
||||
{
|
||||
_logger.Warning($"Redeemable action data received is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
_redemptions.Add(action);
|
||||
_logger.Information($"A new redeemable action has been created [action name: {action.Name}]");
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
|
||||
_logger.Debug($"Filter data [filter id: {filter.Id}][search: {filter.Search}][replace: {filter.Replace}]");
|
||||
_user.RegexFilters.Add(filter);
|
||||
_logger.Information($"Filter has been updated [filter id: {filter.Id}]");
|
||||
_logger.Information($"Filter has been created [filter id: {filter.Id}]");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using HermesSocketServer.Models;
|
||||
using HermesSocketServer.Messages;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Chat.Commands.Limits;
|
||||
using TwitchChatTTS.Chat.Groups;
|
||||
@ -28,7 +28,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
|
||||
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
||||
{
|
||||
var policies = JsonSerializer.Deserialize<IEnumerable<PolicyMessage>>(json, _options);
|
||||
var policies = JsonSerializer.Deserialize<IEnumerable<Policy>>(json, _options);
|
||||
if (policies == null || !policies.Any())
|
||||
{
|
||||
_logger.Information($"No policies have been found. Policies have been set to default.");
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using HermesSocketServer.Models;
|
||||
using HermesSocketServer.Messages;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Chat.Commands.Limits;
|
||||
using TwitchChatTTS.Chat.Groups;
|
||||
@ -24,7 +24,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
|
||||
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
||||
{
|
||||
var policy = JsonSerializer.Deserialize<PolicyMessage>(json, _options);
|
||||
var policy = JsonSerializer.Deserialize<Policy>(json, _options);
|
||||
if (policy == null)
|
||||
{
|
||||
_logger.Warning($"Policy data failed: null");
|
||||
|
35
Hermes/Socket/Requests/UpdateRedeemableActionAck.cs
Normal file
35
Hermes/Socket/Requests/UpdateRedeemableActionAck.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Text.Json;
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Twitch.Redemptions;
|
||||
|
||||
namespace TwitchChatTTS.Hermes.Socket.Requests
|
||||
{
|
||||
public class UpdateRedeemableActionAck : IRequestAck
|
||||
{
|
||||
public string Name => "update_redeemable_action";
|
||||
private readonly IRedemptionManager _redemptions;
|
||||
private readonly JsonSerializerOptions _options;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public UpdateRedeemableActionAck(IRedemptionManager redemptions, JsonSerializerOptions options, ILogger logger)
|
||||
{
|
||||
_redemptions = redemptions;
|
||||
_options = options;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
||||
{
|
||||
var action = JsonSerializer.Deserialize<RedeemableAction>(json, _options);
|
||||
if (action == null)
|
||||
{
|
||||
_logger.Warning($"Redeemable action data received is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
_redemptions.Update(action);
|
||||
_logger.Information($"A new redeemable action has been created [action name: {action.Name}]");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user