Redid stores. Added user store. Added Channel Manager, to manage data from a single channel.

This commit is contained in:
Tom
2024-10-19 01:50:46 +00:00
parent 3f3ba63554
commit 4d0b38babd
22 changed files with 654 additions and 475 deletions

View File

@@ -1,6 +1,7 @@
using HermesSocketLibrary.db;
using HermesSocketLibrary.Requests;
using HermesSocketLibrary.Requests.Messages;
using HermesSocketServer.Store;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
@@ -8,24 +9,23 @@ namespace HermesSocketServer.Requests
public class GetTTSVoices : IRequest
{
public string Name => "get_tts_voices";
private Database _database;
private VoiceStore _voices;
private ILogger _logger;
public GetTTSVoices(Database database, ILogger logger)
public GetTTSVoices(VoiceStore voices, ILogger logger)
{
_database = database;
_voices = voices;
_logger = logger;
}
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
IList<VoiceDetails> voices = new List<VoiceDetails>();
string sql = "SELECT id, name FROM \"TtsVoice\"";
await _database.Execute(sql, (IDictionary<string, object>?) null, (r) => voices.Add(new VoiceDetails()
IEnumerable<VoiceDetails> voices = _voices.Get().Select(v => new VoiceDetails()
{
Id = r.GetString(0),
Name = r.GetString(1)
}));
Id = v.Value.Id,
Name = v.Value.Name
});
_logger.Information($"Fetched all TTS voices for channel [channel: {sender}]");
return new RequestResult(true, voices, notifyClientsOnAccount: false);
}