This repository has been archived on 2023-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
discord-bot-shtik/ConsoleService.cs

50 lines
1.8 KiB
C#
Raw Normal View History

2023-07-03 12:51:23 -04:00
namespace vassago
{
using vassago;
using vassago.Models;
internal class ConsoleService : IHostedService
{
Configuration config = new Configuration();
private List<DiscordInterface.DiscordInterface> discords = new List<DiscordInterface.DiscordInterface>();
private List<TwitchInterface.TwitchInterface> twitchs = new List<TwitchInterface.TwitchInterface>();
2023-07-03 12:51:23 -04:00
public ConsoleService(IConfiguration aspConfig)
{
config.DBConnectionString = aspConfig["DBConnectionString"];
config.ExchangePairsLocation = aspConfig["ExchangePairsLocation"];
config.DiscordTokens = aspConfig.GetSection("DiscordTokens").Get<IEnumerable<string>>();
config.TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
2023-07-03 12:51:23 -04:00
}
public async Task StartAsync(CancellationToken cancellationToken)
{
Shared.DBConnectionString = config.DBConnectionString;
var dbc = new ChattingContext();
dbc.Database.EnsureCreated();
Conversion.Converter.Load(config.ExchangePairsLocation);
if (config.DiscordTokens?.Any() ?? false)
2023-07-03 12:51:23 -04:00
foreach (var dt in config.DiscordTokens)
{
var d = new DiscordInterface.DiscordInterface();
await d.Init(dt);
discords.Add(d);
}
if (config.TwitchConfigs?.Any() ?? false)
foreach (var tc in config.TwitchConfigs)
{
var t = new TwitchInterface.TwitchInterface();
await t.Init(tc);
twitchs.Add(t);
}
2023-07-03 12:51:23 -04:00
}
public Task StopAsync(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
}