Updated Logger. Local plugin database has now only executable dependencies stored in the database

This commit is contained in:
2024-07-01 13:07:34 +03:00
parent fa7e7988d5
commit 9b563cc0f6
10 changed files with 33 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using DiscordBot.Utilities;
@@ -40,9 +41,15 @@ internal static class PluginMethods
internal static async Task RefreshPlugins(bool quiet)
{
try
{
await LoadPlugins(quiet ? ["-q"] : null);
await Application.CurrentApplication.InternalActionManager.Initialize();
}catch(Exception ex)
{
Application.CurrentApplication.Logger.LogException(ex, typeof(PluginMethods), false);
}
await LoadPlugins(quiet ? ["-q"] : null);
await Application.CurrentApplication.InternalActionManager.Initialize();
}
internal static async Task DownloadPlugin(PluginManager manager, string pluginName)
@@ -108,7 +115,7 @@ internal static class PluginMethods
foreach (var dependency in pluginData.Dependencies)
{
var task = ctx.AddTask($"Downloading {dependency.DownloadLocation}: ");
var task = ctx.AddTask($"Downloading {dependency.DownloadLocation} -> Executable: {dependency.IsExecutable}: ");
IProgress<float> progress = new Progress<float>(p =>
{
task.Value = p;

View File

@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
@@ -22,10 +21,10 @@ public class Program
/// </summary>
public static async Task Startup(string[] args)
{
await LoadComponents(args);
await PrepareConsole();
await PluginMethods.LoadPlugins(null);
await Application.CurrentApplication.InternalActionManager.Initialize();
await PluginMethods.RefreshPlugins(false);
await ConsoleInputHandler();
}
@@ -54,7 +53,6 @@ public class Program
/// <returns>Returns the bootloader for the Discord Bot</returns>
private static async Task PrepareConsole()
{
AnsiConsole.MarkupLine($"[yellow]Running on version: {Assembly.GetExecutingAssembly().GetName().Version}[/]");
AnsiConsole.MarkupLine("[yellow]Git SethBot: https://github.com/andreitdr/SethDiscordBot [/]");
AnsiConsole.MarkupLine("[yellow]Git Plugins: https://github.com/andreitdr/SethPlugins [/]");

View File

@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Spectre.Console;
namespace DiscordBot.Utilities;
public static class ConsoleUtilities
internal static class ConsoleUtilities
{
public static async Task<T> ExecuteWithProgressBar<T>(Task<T> function, string message)
{
T result = default;
@@ -28,4 +26,5 @@ public static class ConsoleUtilities
return result;
}
}