about summary refs log tree commit diff
path: root/MatrixUtils.DmSpaced/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixUtils.DmSpaced/Program.cs')
-rw-r--r--MatrixUtils.DmSpaced/Program.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/MatrixUtils.DmSpaced/Program.cs b/MatrixUtils.DmSpaced/Program.cs
new file mode 100644
index 0000000..ae352b7
--- /dev/null
+++ b/MatrixUtils.DmSpaced/Program.cs
@@ -0,0 +1,40 @@
+// See https://aka.ms/new-console-template for more information
+
+using LibMatrix.Services;
+using LibMatrix.Utilities.Bot;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using ModerationBot;
+using ModerationBot.Services;
+
+Console.WriteLine("Hello, World!");
+
+var builder = Host.CreateDefaultBuilder(args);
+
+builder.ConfigureHostOptions(host => {
+    host.ServicesStartConcurrently = true;
+    host.ServicesStopConcurrently = true;
+    host.ShutdownTimeout = TimeSpan.FromSeconds(5);
+});
+
+if (Environment.GetEnvironmentVariable("MODERATIONBOT_APPSETTINGS_PATH") is string path)
+    builder.ConfigureAppConfiguration(x => x.AddJsonFile(path));
+
+var host = builder.ConfigureServices((_, services) => {
+    services.AddScoped<TieredStorageService>(x =>
+        new TieredStorageService(
+            cacheStorageProvider: new FileStorageProvider("bot_data/cache/"),
+            dataStorageProvider: new FileStorageProvider("bot_data/data/")
+        )
+    );
+    services.AddSingleton<ModerationBotConfiguration>();
+
+    services.AddRoryLibMatrixServices();
+
+    services.AddSingleton<ModerationBotRoomProvider>();
+
+    services.AddHostedService<ModerationBot.ModerationBot>();
+}).UseConsoleLifetime().Build();
+
+await host.RunAsync();
\ No newline at end of file