Added several request messages. Added redemptions. Added life TTS voice changes. A bunch of stuffs.

This commit is contained in:
Tom
2024-08-10 19:36:32 +00:00
parent 95bc073a73
commit c771a56971
36 changed files with 552 additions and 235 deletions

View File

@@ -17,8 +17,14 @@ namespace HermesSocketServer.Requests
_logger = logger;
}
public async Task<RequestResult> Grant(string sender, IDictionary<string, object> data)
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
if (data == null)
{
_logger.Warning("Data received from request is null. Ignoring it.");
return new RequestResult(false, null);
}
if (long.TryParse(data["chatter"].ToString(), out long chatter))
data["chatter"] = chatter;
if (data["voice"] is JsonElement v)
@@ -26,13 +32,12 @@ namespace HermesSocketServer.Requests
data["user"] = sender;
var check = await _database.ExecuteScalar("SELECT state FROM \"TtsVoiceState\" WHERE \"userId\" = @user AND \"ttsVoiceId\" = @voice", data) ?? false;
if (check is not bool state || !state){
if (check is not bool state || !state)
return new RequestResult(false, null);
}
string sql = "INSERT INTO \"TtsChatVoice\" (\"userId\", \"chatterId\", \"ttsVoiceId\") VALUES (@user, @chatter, @voice)";
var result = await _database.Execute(sql, data);
_logger.Information($"Selected a tts voice for {data["chatter"]} in channel {data["user"]}: {data["voice"]}");
_logger.Information($"Selected a tts voice [voice: {data["voice"]}] for user [chatter: {data["chatter"]}] in channel [channel: {data["user"]}]");
return new RequestResult(result == 1, null);
}
}