-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
53 lines (46 loc) · 1.78 KB
/
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
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
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Cerberus.Database;
using Cerberus.VRChat;
namespace Cerberus {
public static class Program {
public static async Task Main(string[] args) {
DotEnv envVars = new DotEnv();
string token = envVars.Get("DISCORD_TOKEN");
string dbAddress = envVars.Get("REDIS_ADDRESS");
string vrcUsername = envVars.Get("VRC_USERNAME");
string vrcPassword = envVars.Get("VRC_PASSWORD");
DatabaseMiddleware db = await DatabaseMiddleware.ConnectAsync(dbAddress);
VrchatLoginCredentials credentials = new VrchatLoginCredentials {
Username = vrcUsername,
Password = vrcPassword
};
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#elif RELEASE
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((ctx, collection) => {
collection.AddSingleton(Log.Logger);
collection.AddSingleton<VRChatAPI>();
collection.AddSingleton<DatabaseMiddleware>(db);
collection.AddSingleton<VrchatLoginCredentials>(credentials);
collection.AddSingleton<String>(token);
collection.AddSingleton<IHostedService, LoonieBot>();
})
.UseSerilog()
.Build();
await host.RunAsync();
}
}
}