using HermesSocketLibrary.db; using HermesSocketServer.Models; using HermesSocketServer.Store.Internal; namespace HermesSocketServer.Store { public class ChatterStore : AutoSavedStore { private readonly string _userId; private readonly Database _database; private readonly Serilog.ILogger _logger; public ChatterStore(string userId, DatabaseTable table, Database database, Serilog.ILogger logger) : base(table, database, logger) { _userId = userId; _database = database; _logger = logger; } public override async Task Load() { var data = new Dictionary() { { "user", _userId } }; string sql = $"SELECT \"chatterId\", \"ttsVoiceId\" FROM \"TtsChatVoice\" WHERE \"userId\" = @user"; await _database.Execute(sql, data, (reader) => { var chatterId = reader.GetInt64(0); _store.Add(chatterId.ToString(), new ChatterVoice() { UserId = _userId, ChatterId = chatterId, VoiceId = reader.GetString(1) }); }); _logger.Information($"Loaded {_store.Count} TTS chatter voices from database."); } protected override void OnInitialAdd(string key, ChatterVoice value) { } protected override void OnInitialModify(string key, ChatterVoice value) { } protected override void OnInitialRemove(string key) { } } }