feat: migrate to use options monitor

This commit is contained in:
Stevan Freeborn
2026-03-13 12:28:08 -05:00
parent 6cd0fdae62
commit 313336aa99
@@ -6,17 +6,17 @@ namespace GroundsForSupport.Server.TextToSpeech;
internal sealed class StreamerBotService(
IHttpClientFactory httpClientFactory,
IOptions<StreamerBotOptions> options
IOptionsMonitor<StreamerBotOptions> options
) : IStreamerBotService
{
private const string DoActionEndpoint = "/DoAction";
private readonly IHttpClientFactory _httpClientFactory = httpClientFactory;
private readonly StreamerBotOptions _options = options.Value;
private readonly IOptionsMonitor<StreamerBotOptions> _options = options;
public Task TriggerTextToSpeechAsync(string name, long amount, string message, CancellationToken cancellationToken = default)
{
var client = _httpClientFactory.CreateClient();
var url = new UriBuilder(_options.GetBaseUrl())
var url = new UriBuilder(_options.CurrentValue.GetBaseUrl())
{
Path = DoActionEndpoint
}.Uri;
@@ -27,14 +27,14 @@ internal sealed class StreamerBotService(
{
action = new
{
id = _options.TextToSpeechActionId
id = _options.CurrentValue.TextToSpeechActionId
},
args = new
{
name,
amount = $"${amount / 100.0:F2}",
message,
apiKey = _options.ApiKey
apiKey = _options.CurrentValue.ApiKey
}
};