-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (64 loc) · 2.15 KB
/
Program.cs
File metadata and controls
72 lines (64 loc) · 2.15 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using Bot.Enums;
using Bot.StartupTasks;
using Bot.Utils.Logging;
using Serilog.Events;
namespace Bot;
internal class Program
{
private static async Task Main()
{
AppContext.SetSwitch("System.Net.DisableIPv6", true);
StartupTaskRunner runner = new StartupTaskRunner()
.Add<LoadConfig>()
.Add<LoggerSetup>()
.Add<RedisSetup>()
.Add<NpgsqlSetup>()
.Add<LoadInMemorySettings>()
.Add<MainClientSetup>()
.Add<AnonClientSetup>()
.Add<FetchPermissions>()
.Add<ChannelsSetup>()
.Add<PubSubSetup>()
.Add<CreateHelixClient>()
.Add<LoadModules>()
.Add<InitHandlers>()
.Add<StartMetrics>();
await foreach (StartupTaskState result in runner.RunAll())
if (result != StartupTaskState.Completed)
throw new NotSupportedException(result.ToString());
if (Environment.GetEnvironmentVariable("SERVICE") is "TRUE")
{
Console.WriteLine("Running as a service -- Console input is disabled.");
await Task.Delay(-1);
return;
}
while (true)
{
string? input = Console.ReadLine();
if (string.IsNullOrEmpty(input))
continue;
if (Enum.TryParse(input, true, out LogEventLevel level))
{
await Settings.ChangeLogLevel((int)level);
Console.WriteLine($"Switching logging level to: {level}");
}
else if (input == "clear")
{
Console.Clear();
}
else if (input.StartsWith("l!include"))
{
string[] args = input.Split(' ');
if (args.Length < 2)
continue;
ClassNameFilter.ClassName = args[1];
Console.WriteLine($"ClassNameFilter set to {args[1]}");
}
else if (input == "l!unfilter")
{
ClassNameFilter.ClassName = null;
Console.WriteLine("Removed all filters");
}
}
}
}