From 9dcce18cda5317ea1150eed06d6589b6285577e6 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 4 Sep 2023 06:29:00 +0200 Subject: Add start of Media Moderator PoC bot --- LibMatrix.ExampleBot/Bot/FileStorageProvider.cs | 39 ------------------------- 1 file changed, 39 deletions(-) delete mode 100644 LibMatrix.ExampleBot/Bot/FileStorageProvider.cs (limited to 'LibMatrix.ExampleBot/Bot/FileStorageProvider.cs') 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 _logger; - - public string TargetPath { get; } - - /// - /// Creates a new instance of . - /// - /// - public FileStorageProvider(string targetPath) { - new Logger(new LoggerFactory()).LogInformation("test"); - Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}"); - TargetPath = targetPath; - if(!Directory.Exists(targetPath)) { - Directory.CreateDirectory(targetPath); - } - } - - public async Task SaveObjectAsync(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson()); - - public async Task LoadObjectAsync(string key) => JsonSerializer.Deserialize(await File.ReadAllTextAsync(Path.Join(TargetPath, key))); - - public Task ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key))); - - public Task> GetAllKeysAsync() => Task.FromResult(Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList()); - - public Task DeleteObjectAsync(string key) { - File.Delete(Path.Join(TargetPath, key)); - return Task.CompletedTask; - } -} -- cgit 1.4.1