hermes-server/Requests/GetDefaultTTSVoice.cs
2024-12-28 17:24:02 +00:00

31 lines
1.1 KiB
C#

using HermesSocketServer.Models;
using HermesSocketServer.Store;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class GetDefaultTTSVoice : IRequest
{
public string Name => "get_default_tts_voice";
public string[] RequiredKeys => [];
private readonly UserStore _users;
private readonly ServerConfiguration _configuration;
private readonly ILogger _logger;
public GetDefaultTTSVoice(UserStore users, ServerConfiguration configuration, ILogger logger)
{
_users = users;
_configuration = configuration;
_logger = logger;
}
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
{
var user = _users.Get(channel.Id);
if (user == null)
return Task.FromResult(RequestResult.Failed("Unable to find user data.", notifyClientsOnAccount: false));
return Task.FromResult(RequestResult.Successful(user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false));
}
}
}