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