hermes-server/Requests/DeleteTTSFilter.cs

32 lines
1016 B
C#

using HermesSocketServer.Models;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class DeleteTTSFilter : IRequest
{
public string Name => "delete_tts_filter";
public string[] RequiredKeys => ["id"];
private ILogger _logger;
public DeleteTTSFilter(ILogger logger)
{
_logger = logger;
}
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
{
string filterId = data["id"].ToString()!;
var result = channel.Filters.Remove(filterId);
if (result)
{
_logger.Information($"Deleted a TTS filter by id [tts filter id: {filterId}]");
return Task.FromResult(RequestResult.Successful(null));
}
_logger.Warning($"Filter ID does not exist [id: {filterId}]");
return Task.FromResult(RequestResult.Failed("Filter ID does not exist."));
}
}
}