vassago/ConsoleService.cs
adam 740471d105
Some checks failed
gitea.arg.rip/vassago/pipeline/head There was a failure building this commit
rememberer. but it doesn't remember.
FUCK this is what I get for saying I like entity framework. *adds thing* *hits save* "(unrelated shit) is already here, why are you trying to add it again you dumbass?" FUCK IF I KNOW, you're supposed to be straightening this shit out!
2025-02-07 17:00:29 -05:00

49 lines
1.6 KiB
C#

namespace vassago
{
using Microsoft.EntityFrameworkCore;
using vassago;
using vassago.Models;
using vassago.TwitchInterface;
internal class ConsoleService : IHostedService
{
public ConsoleService(IConfiguration aspConfig)
{
Shared.DBConnectionString = aspConfig["DBConnectionString"];
DiscordTokens = aspConfig.GetSection("DiscordTokens").Get<IEnumerable<string>>();
TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]);
}
IEnumerable<string> DiscordTokens { get; }
IEnumerable<TwitchConfig> TwitchConfigs { get; }
public async Task StartAsync(CancellationToken cancellationToken)
{
var dbc = new ChattingContext();
await dbc.Database.MigrateAsync();
if (DiscordTokens?.Any() ?? false)
foreach (var dt in DiscordTokens)
{
var d = new DiscordInterface.DiscordInterface();
await d.Init(dt);
ProtocolInterfaces.ProtocolList.discords.Add(d);
}
if (TwitchConfigs?.Any() ?? false)
foreach (var tc in TwitchConfigs)
{
var t = new TwitchInterface.TwitchInterface();
await t.Init(tc);
ProtocolInterfaces.ProtocolList.twitchs.Add(t);
}
}
public Task StopAsync(CancellationToken cancellationToken)
{
return null;
}
}
}