about summary refs log tree commit diff
path: root/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 06:29:00 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 06:29:00 +0200
commit9dcce18cda5317ea1150eed06d6589b6285577e6 (patch)
tree1b36a9ddffa312e58daab075c43fb482c2bae905 /LibMatrix.ExampleBot/Bot/FileStorageProvider.cs
parentToo many changes to name... (diff)
downloadLibMatrix-9dcce18cda5317ea1150eed06d6589b6285577e6.tar.xz
Add start of Media Moderator PoC bot
Diffstat (limited to 'LibMatrix.ExampleBot/Bot/FileStorageProvider.cs')
-rw-r--r--LibMatrix.ExampleBot/Bot/FileStorageProvider.cs39
1 files changed, 0 insertions, 39 deletions
diff --git a/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs b/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs
deleted file mode 100644
index 2dfcee5..0000000
--- a/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Text.Json;
-using ArcaneLibs.Extensions;
-using LibMatrix.Extensions;
-using LibMatrix.Interfaces.Services;
-using Microsoft.Extensions.Logging;
-
-namespace LibMatrix.ExampleBot.Bot;
-
-public class FileStorageProvider : IStorageProvider {
-    private readonly ILogger<FileStorageProvider> _logger;
-
-    public string TargetPath { get; }
-
-    /// <summary>
-    /// Creates a new instance of <see cref="FileStorageProvider" />.
-    /// </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)) {
-            Directory.CreateDirectory(targetPath);
-        }
-    }
-
-    public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson());
-
-    public async Task<T?> LoadObjectAsync<T>(string key) => JsonSerializer.Deserialize<T>(await File.ReadAllTextAsync(Path.Join(TargetPath, key)));
-
-    public Task<bool> ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key)));
-
-    public Task<List<string>> GetAllKeysAsync() => Task.FromResult(Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList());
-
-    public Task DeleteObjectAsync(string key) {
-        File.Delete(Path.Join(TargetPath, key));
-        return Task.CompletedTask;
-    }
-}