Revised the redeem system, activated via channel point redeems. Added OBS transformation to redeems. Logs changed & writes to logs folder as well. Removed most use of IServiceProvider.

This commit is contained in:
Tom
2024-06-24 22:11:36 +00:00
parent 706cd06930
commit 706eecf2d2
45 changed files with 964 additions and 577 deletions

View File

@@ -9,33 +9,34 @@ public class SevenApiClient
public static readonly string API_URL = "https://7tv.io/v3";
public static readonly string WEBSOCKET_URL = "wss://events.7tv.io/v3";
private WebClientWrap Web { get; }
private ILogger Logger { get; }
private readonly WebClientWrap _web;
private readonly ILogger _logger;
public SevenApiClient(ILogger logger)
{
Logger = logger;
Web = new WebClientWrap(new JsonSerializerOptions()
_logger = logger;
_web = new WebClientWrap(new JsonSerializerOptions()
{
PropertyNameCaseInsensitive = false,
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
});
}
public async Task<EmoteSet?> FetchChannelEmoteSet(string twitchId) {
public async Task<EmoteSet?> FetchChannelEmoteSet(string twitchId)
{
try
{
var details = await Web.GetJson<UserDetails>($"{API_URL}/users/twitch/" + twitchId);
var details = await _web.GetJson<UserDetails>($"{API_URL}/users/twitch/" + twitchId);
return details?.EmoteSet;
}
catch (JsonException e)
{
Logger.Error(e, "Failed to fetch emotes from 7tv due to improper JSON.");
_logger.Error(e, "Failed to fetch emotes from 7tv due to improper JSON.");
}
catch (Exception e)
{
Logger.Error(e, "Failed to fetch emotes from 7tv.");
_logger.Error(e, "Failed to fetch emotes from 7tv.");
}
return null;
}
@@ -44,16 +45,16 @@ public class SevenApiClient
{
try
{
var emoteSet = await Web.GetJson<EmoteSet>($"{API_URL}/emote-sets/6353512c802a0e34bac96dd2");
var emoteSet = await _web.GetJson<EmoteSet>($"{API_URL}/emote-sets/6353512c802a0e34bac96dd2");
return emoteSet?.Emotes;
}
catch (JsonException e)
{
Logger.Error(e, "Failed to fetch emotes from 7tv due to improper JSON.");
_logger.Error(e, "Failed to fetch emotes from 7tv due to improper JSON.");
}
catch (Exception e)
{
Logger.Error(e, "Failed to fetch emotes from 7tv.");
_logger.Error(e, "Failed to fetch emotes from 7tv.");
}
return null;
}