2023-07-03 12:51:23 -04:00
|
|
|
namespace vassago
|
|
|
|
{
|
2023-12-05 23:15:09 -05:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-07-03 12:51:23 -04:00
|
|
|
using vassago;
|
|
|
|
using vassago.Models;
|
2023-07-04 18:51:27 -04:00
|
|
|
using vassago.TwitchInterface;
|
2023-07-03 12:51:23 -04:00
|
|
|
|
|
|
|
internal class ConsoleService : IHostedService
|
|
|
|
{
|
|
|
|
|
|
|
|
public ConsoleService(IConfiguration aspConfig)
|
|
|
|
{
|
2023-07-04 19:25:04 -04:00
|
|
|
Shared.DBConnectionString = aspConfig["DBConnectionString"];
|
|
|
|
DiscordTokens = aspConfig.GetSection("DiscordTokens").Get<IEnumerable<string>>();
|
|
|
|
TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
|
|
|
|
Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]);
|
2023-07-03 12:51:23 -04:00
|
|
|
}
|
|
|
|
|
2023-07-04 19:25:04 -04:00
|
|
|
IEnumerable<string> DiscordTokens { get; }
|
|
|
|
IEnumerable<TwitchConfig> TwitchConfigs { get; }
|
|
|
|
|
2023-07-03 12:51:23 -04:00
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
var dbc = new ChattingContext();
|
2024-01-05 22:12:57 -05:00
|
|
|
await dbc.Database.MigrateAsync();
|
2023-07-03 12:51:23 -04:00
|
|
|
|
2023-07-04 19:25:04 -04:00
|
|
|
if (DiscordTokens?.Any() ?? false)
|
|
|
|
foreach (var dt in DiscordTokens)
|
2023-07-03 12:51:23 -04:00
|
|
|
{
|
|
|
|
var d = new DiscordInterface.DiscordInterface();
|
|
|
|
await d.Init(dt);
|
2023-07-04 18:51:27 -04:00
|
|
|
ProtocolInterfaces.ProtocolList.discords.Add(d);
|
2023-07-03 12:51:23 -04:00
|
|
|
}
|
2023-07-04 12:58:21 -04:00
|
|
|
|
2023-07-04 19:25:04 -04:00
|
|
|
if (TwitchConfigs?.Any() ?? false)
|
|
|
|
foreach (var tc in TwitchConfigs)
|
2023-07-04 12:58:21 -04:00
|
|
|
{
|
|
|
|
var t = new TwitchInterface.TwitchInterface();
|
|
|
|
await t.Init(tc);
|
2023-07-04 18:51:27 -04:00
|
|
|
ProtocolInterfaces.ProtocolList.twitchs.Add(t);
|
2023-07-04 12:58:21 -04:00
|
|
|
}
|
2024-01-10 21:21:31 -05:00
|
|
|
Console.WriteLine("survived initting");
|
2023-07-03 12:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
|
|
|
{
|
2024-04-05 22:15:59 -04:00
|
|
|
return null;
|
2023-07-03 12:51:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|