33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using HermesSocketServer.Models;
|
|
using HermesSocketServer.Store;
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
namespace HermesSocketServer.Requests
|
|
{
|
|
public class UpdateDefaultTTSVoice : IRequest
|
|
{
|
|
public string Name => "update_default_tts_voice";
|
|
public string[] RequiredKeys => ["user", "voice"];
|
|
private UserStore _users;
|
|
private ILogger _logger;
|
|
|
|
public UpdateDefaultTTSVoice(UserStore users, ILogger logger)
|
|
{
|
|
_users = users;
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
|
{
|
|
string user = data["user"].ToString()!;
|
|
string voice = data["voice"].ToString()!;
|
|
|
|
var success = _users.Modify(user, (user) => user.DefaultVoice = voice);
|
|
if (!success)
|
|
return RequestResult.Failed("Unable to find user data.");
|
|
|
|
_logger.Information($"Updated default TTS voice for channel [channel: {channel.Id}][voice: {voice}]");
|
|
return RequestResult.Successful(null);
|
|
}
|
|
}
|
|
} |