using System.Text.Json; using Serilog; using TwitchChatTTS.Chat.Groups; namespace TwitchChatTTS.Hermes.Socket.Requests { public class DeleteGroupAck : IRequestAck { public string Name => "delete_group"; private readonly IChatterGroupManager _groups; private readonly JsonSerializerOptions _options; private readonly ILogger _logger; public DeleteGroupAck(IChatterGroupManager groups, JsonSerializerOptions options, ILogger logger) { _groups = groups; _options = options; _logger = logger; } public void Acknowledge(string requestId, string? json, IDictionary? requestData) { if (requestData == null) { _logger.Warning("Request data is null."); return; } var groupId = requestData["group"].ToString(); if (string.IsNullOrEmpty(groupId)) { _logger.Warning($"Action name is invalid [action name: {groupId}]"); return; } var group = _groups.Get(groupId); if (group == null) { _logger.Warning($"Group id does not exist [group id: {group}]"); return; } _logger.Debug($"Removing group [group id: {group.Id}][group name: {group.Name}][group priority: {group.Priority}]"); _groups.Remove(group.Id); _logger.Information($"Group has been updated [group id: {group.Id}]"); } } }