-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
25 lines (21 loc) · 954 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Discord.Webhook;
using YoutubeLiveChatToDiscord;
using YoutubeLiveChatToDiscord.Services;
Environment.SetEnvironmentVariable("VIDEO_ID", Environment.GetCommandLineArgs()[1]);
Environment.SetEnvironmentVariable("WEBHOOK", Environment.GetCommandLineArgs()[2]);
IEnumerable<string> oldFiles = Directory.GetFiles(Directory.GetCurrentDirectory())
.Where(p => p.Contains($"{Environment.GetEnvironmentVariable("VIDEO_ID")}.live_chat.json"));
foreach (var file in oldFiles)
{
File.Delete(file);
}
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<LiveChatMonitorWorker>()
.AddSingleton<LiveChatDownloadService>()
.AddSingleton<DiscordService>()
.AddSingleton((service) => new DiscordWebhookClient(Environment.GetEnvironmentVariable("WEBHOOK")));
})
.Build();
await host.RunAsync();