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( internal sealed class StreamerBotService(
IHttpClientFactory httpClientFactory, IHttpClientFactory httpClientFactory,
IOptions<StreamerBotOptions> options IOptionsMonitor<StreamerBotOptions> options
) : IStreamerBotService ) : IStreamerBotService
{ {
private const string DoActionEndpoint = "/DoAction"; private const string DoActionEndpoint = "/DoAction";
private readonly IHttpClientFactory _httpClientFactory = httpClientFactory; 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) public Task TriggerTextToSpeechAsync(string name, long amount, string message, CancellationToken cancellationToken = default)
{ {
var client = _httpClientFactory.CreateClient(); var client = _httpClientFactory.CreateClient();
var url = new UriBuilder(_options.GetBaseUrl()) var url = new UriBuilder(_options.CurrentValue.GetBaseUrl())
{ {
Path = DoActionEndpoint Path = DoActionEndpoint
}.Uri; }.Uri;
@@ -27,14 +27,14 @@ internal sealed class StreamerBotService(
{ {
action = new action = new
{ {
id = _options.TextToSpeechActionId id = _options.CurrentValue.TextToSpeechActionId
}, },
args = new args = new
{ {
name, name,
amount = $"${amount / 100.0:F2}", amount = $"${amount / 100.0:F2}",
message, message,
apiKey = _options.ApiKey apiKey = _options.CurrentValue.ApiKey
} }
}; };