about summary refs log tree commit diff
path: root/Utilities/LibMatrix.Utilities.Bot
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/LibMatrix.Utilities.Bot')
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/AppServiceConfiguration.cs4
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/BotCommandInstaller.cs4
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/FileStorageProvider.cs4
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs6
4 files changed, 7 insertions, 11 deletions
diff --git a/Utilities/LibMatrix.Utilities.Bot/AppServiceConfiguration.cs b/Utilities/LibMatrix.Utilities.Bot/AppServiceConfiguration.cs
index 99a789a..d8d1094 100644
--- a/Utilities/LibMatrix.Utilities.Bot/AppServiceConfiguration.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/AppServiceConfiguration.cs
@@ -44,8 +44,8 @@ public class AppServiceConfiguration {
         else
             yaml += "protocols: []";
         yaml += "\n";
-        if (RateLimited is not null)
-            yaml += $"rate_limited: {RateLimited!.ToString().ToLower()}\n";
+        if (RateLimited.HasValue)
+            yaml += $"rate_limited: {RateLimited.Value.ToString().ToLower()}\n";
         else
             yaml += "rate_limited: false\n";
 
diff --git a/Utilities/LibMatrix.Utilities.Bot/BotCommandInstaller.cs b/Utilities/LibMatrix.Utilities.Bot/BotCommandInstaller.cs
index 91ec1e8..25a8d92 100644
--- a/Utilities/LibMatrix.Utilities.Bot/BotCommandInstaller.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/BotCommandInstaller.cs
@@ -21,8 +21,8 @@ public static class BotCommandInstaller {
         services.AddSingleton<LibMatrixBotConfiguration>();
 
         services.AddScoped<AuthenticatedHomeserverGeneric>(x => {
-            var config = x.GetService<LibMatrixBotConfiguration>();
-            var hsProvider = x.GetService<HomeserverProviderService>();
+            var config = x.GetService<LibMatrixBotConfiguration>() ?? throw new Exception("No configuration found!");
+            var hsProvider = x.GetService<HomeserverProviderService>() ?? throw new Exception("No homeserver provider found!");
             var hs = hsProvider.GetAuthenticatedWithToken(config.Homeserver, config.AccessToken).Result;
 
             return hs;
diff --git a/Utilities/LibMatrix.Utilities.Bot/FileStorageProvider.cs b/Utilities/LibMatrix.Utilities.Bot/FileStorageProvider.cs
index 46032c7..b66fbf5 100644
--- a/Utilities/LibMatrix.Utilities.Bot/FileStorageProvider.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/FileStorageProvider.cs
@@ -1,13 +1,10 @@
 using System.Text.Json;
 using ArcaneLibs.Extensions;
 using LibMatrix.Interfaces.Services;
-using Microsoft.Extensions.Logging;
 
 namespace LibMatrix.Utilities.Bot;
 
 public class FileStorageProvider : IStorageProvider {
-    private readonly ILogger<FileStorageProvider> _logger;
-
     public string TargetPath { get; }
 
     /// <summary>
@@ -15,7 +12,6 @@ public class FileStorageProvider : IStorageProvider {
     /// </summary>
     /// <param name="targetPath"></param>
     public FileStorageProvider(string targetPath) {
-        new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test");
         Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}");
         TargetPath = targetPath;
         if (!Directory.Exists(targetPath)) {
diff --git a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
index 2d04e37..94ea846 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
@@ -5,8 +5,8 @@ using LibMatrix.RoomTypes;
 namespace LibMatrix.Utilities.Bot.Interfaces;
 
 public class CommandContext {
-    public GenericRoom Room { get; set; }
-    public StateEventResponse MessageEvent { get; set; }
+    public required GenericRoom Room { get; set; }
+    public required StateEventResponse MessageEvent { get; set; }
 
     public string MessageContentWithoutReply =>
         (MessageEvent.TypedContent as RoomMessageEventContent)!
@@ -16,7 +16,7 @@ public class CommandContext {
 
     public string CommandName => MessageContentWithoutReply.Split(' ')[0][1..];
     public string[] Args => MessageContentWithoutReply.Split(' ')[1..];
-    public AuthenticatedHomeserverGeneric Homeserver { get; set; }
+    public required AuthenticatedHomeserverGeneric Homeserver { get; set; }
 
     public async Task<EventIdResponse> Reply(RoomMessageEventContent content) => await Room.SendMessageEventAsync(content);
 }