The library can now be used for Windows exclusive bots (Made with WinForm or Wpf)
This commit is contained in:
@@ -195,7 +195,7 @@ public class Program
|
|||||||
private static void NoGUI()
|
private static void NoGUI()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
ConsoleCommandsHandler.ExecuteCommad("lp").Wait();
|
ConsoleCommandsHandler.ExecuteCommad("lp").Wait();
|
||||||
#else
|
#else
|
||||||
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
||||||
@@ -211,7 +211,7 @@ public class Program
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
) && cmd.Length > 0)
|
) && cmd.Length > 0)
|
||||||
Settings.Variables.outputStream.WriteLine("Failed to run command " + cmd);
|
Logger.WriteLine("Failed to run command " + cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,11 +229,11 @@ public class Program
|
|||||||
"https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/StartupMessage");
|
"https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/StartupMessage");
|
||||||
|
|
||||||
foreach (var message in startupMessageList)
|
foreach (var message in startupMessageList)
|
||||||
Settings.Variables.outputStream.WriteLine(message);
|
Logger.WriteLine(message);
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine(
|
Logger.WriteLine(
|
||||||
$"Running on version: {Assembly.GetExecutingAssembly().GetName().Version}");
|
$"Running on version: {Assembly.GetExecutingAssembly().GetName().Version}");
|
||||||
Settings.Variables.outputStream.WriteLine($"Git URL: {Settings.Variables.WebsiteURL}");
|
Logger.WriteLine($"Git URL: {Settings.Variables.WebsiteURL}");
|
||||||
|
|
||||||
Utilities.WriteColorText(
|
Utilities.WriteColorText(
|
||||||
"&rRemember to close the bot using the ShutDown command (&ysd&r) or some settings won't be saved\n");
|
"&rRemember to close the bot using the ShutDown command (&ysd&r) or some settings won't be saved\n");
|
||||||
@@ -245,7 +245,7 @@ public class Program
|
|||||||
|
|
||||||
Utilities.WriteColorText(
|
Utilities.WriteColorText(
|
||||||
"Please note that the bot saves a backup save file every time you are using the shudown command (&ysd&c)");
|
"Please note that the bot saves a backup save file every time you are using the shudown command (&ysd&c)");
|
||||||
Settings.Variables.outputStream.WriteLine("============================ LOG ============================");
|
Logger.WriteLine("============================ LOG ============================");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -254,7 +254,7 @@ public class Program
|
|||||||
|
|
||||||
if (await Settings.sqlDatabase.TableExistsAsync("BetaTest"))
|
if (await Settings.sqlDatabase.TableExistsAsync("BetaTest"))
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine("Starting in DEBUG MODE");
|
Logger.WriteLine("Starting in DEBUG MODE");
|
||||||
token = await Settings.sqlDatabase.GetValueAsync("BetaTest", "VariableName", "Token", "Value");
|
token = await Settings.sqlDatabase.GetValueAsync("BetaTest", "VariableName", "Token", "Value");
|
||||||
}
|
}
|
||||||
else token = Config.Variables.GetValue("token");
|
else token = Config.Variables.GetValue("token");
|
||||||
@@ -268,7 +268,7 @@ public class Program
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine(ex);
|
Logger.LogError(ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ public class Program
|
|||||||
if (len > 0 && args[0] == "/remplug")
|
if (len > 0 && args[0] == "/remplug")
|
||||||
{
|
{
|
||||||
var plugName = string.Join(' ', args, 1, args.Length - 1);
|
var plugName = string.Join(' ', args, 1, args.Length - 1);
|
||||||
Settings.Variables.outputStream.WriteLine("Starting to remove " + plugName);
|
Logger.WriteLine("Starting to remove " + plugName);
|
||||||
await ConsoleCommandsHandler.ExecuteCommad("remplug " + plugName);
|
await ConsoleCommandsHandler.ExecuteCommad("remplug " + plugName);
|
||||||
loadPluginsOnStartup = true;
|
loadPluginsOnStartup = true;
|
||||||
}
|
}
|
||||||
@@ -318,8 +318,12 @@ public class Program
|
|||||||
|
|
||||||
private static async Task PreLoadComponents()
|
private static async Task PreLoadComponents()
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream = Console.Out;
|
Logger.LogEvent += (message) =>
|
||||||
Settings.Variables.outputStream.WriteLine("Loading resources ...");
|
{
|
||||||
|
Console.Write(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
Logger.WriteLine("Loading resources ...");
|
||||||
var main = new Utilities.ProgressBar(ProgressBarType.NO_END);
|
var main = new Utilities.ProgressBar(ProgressBarType.NO_END);
|
||||||
main.Start();
|
main.Start();
|
||||||
Directory.CreateDirectory("./Data/Resources");
|
Directory.CreateDirectory("./Data/Resources");
|
||||||
@@ -390,19 +394,19 @@ public class Program
|
|||||||
|
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine("A new version of the bot is available !");
|
Logger.WriteLine("A new version of the bot is available !");
|
||||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
Console.WriteLine("Current version : " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
Logger.WriteLine("Current version : " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine("New version : " + newVersion);
|
Logger.WriteLine("New version : " + newVersion);
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
|
||||||
Console.WriteLine("Changelog :");
|
Logger.WriteLine("Changelog :");
|
||||||
|
|
||||||
List<string> changeLog = await ServerCom.ReadTextFromURL("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/VersionData/DiscordBot");
|
List<string> changeLog = await ServerCom.ReadTextFromURL("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/VersionData/DiscordBot");
|
||||||
foreach (var item in changeLog)
|
foreach (var item in changeLog)
|
||||||
Utilities.WriteColorText(item);
|
Utilities.WriteColorText(item);
|
||||||
Console.WriteLine("Do you want to update the bot ? (y/n)");
|
Logger.WriteLine("Do you want to update the bot ? (y/n)");
|
||||||
if (Console.ReadKey().Key == ConsoleKey.Y)
|
if (Console.ReadKey().Key == ConsoleKey.Y)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -418,7 +422,7 @@ public class Program
|
|||||||
{
|
{
|
||||||
var url =
|
var url =
|
||||||
$"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip";
|
$"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip";
|
||||||
Settings.Variables.outputStream.WriteLine("Downloading update ...");
|
Logger.WriteLine("Downloading update ...");
|
||||||
await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip");
|
await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip");
|
||||||
await File.WriteAllTextAsync("Install.sh",
|
await File.WriteAllTextAsync("Install.sh",
|
||||||
"#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot");
|
"#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot");
|
||||||
@@ -441,7 +445,7 @@ public class Program
|
|||||||
!File.Exists("./Updater/Updater.exe"))
|
!File.Exists("./Updater/Updater.exe"))
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Settings.Variables.outputStream.WriteLine("Installing updater ...\nDo NOT close the bot during update !");
|
Logger.WriteLine("Installing updater ...\nDo NOT close the bot during update !");
|
||||||
var bar = new Utilities.ProgressBar(ProgressBarType.NO_END);
|
var bar = new Utilities.ProgressBar(ProgressBarType.NO_END);
|
||||||
bar.Start();
|
bar.Start();
|
||||||
await ServerCom.DownloadFileNoProgressAsync(
|
await ServerCom.DownloadFileNoProgressAsync(
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class ConsoleCommandsHandler
|
|||||||
InitializeBasicCommands();
|
InitializeBasicCommands();
|
||||||
|
|
||||||
|
|
||||||
//Settings.Variables.outputStream.WriteLine("Initialized console command handler !");
|
//Logger.WriteLine("Initialized console command handler !");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeBasicCommands()
|
private void InitializeBasicCommands()
|
||||||
@@ -46,7 +46,7 @@ public class ConsoleCommandsHandler
|
|||||||
{
|
{
|
||||||
if (args.Length <= 1)
|
if (args.Length <= 1)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine("Available commands:");
|
Logger.WriteLine("Available commands:");
|
||||||
var items = new List<string[]>();
|
var items = new List<string[]>();
|
||||||
items.Add(new[] { "-", "-", "-" });
|
items.Add(new[] { "-", "-", "-" });
|
||||||
items.Add(new[] { "Command", "Description", "Usage" });
|
items.Add(new[] { "Command", "Description", "Usage" });
|
||||||
@@ -69,12 +69,12 @@ public class ConsoleCommandsHandler
|
|||||||
foreach (var command in commandList)
|
foreach (var command in commandList)
|
||||||
if (command.CommandName == args[1])
|
if (command.CommandName == args[1])
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine("Command description: " + command.Description);
|
Logger.WriteLine("Command description: " + command.Description);
|
||||||
Settings.Variables.outputStream.WriteLine("Command execution format:" + command.Usage);
|
Logger.WriteLine("Command execution format:" + command.Usage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine("Command not found");
|
Logger.WriteLine("Command not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -93,16 +93,16 @@ public class ConsoleCommandsHandler
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Settings.Variables.outputStream.WriteLine("[CMD] Successfully loaded command : " + name);
|
Logger.WriteLine("[CMD] Successfully loaded command : " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
if (exception is null)
|
if (exception is null)
|
||||||
Settings.Variables.outputStream.WriteLine("An error occured while loading: " + name);
|
Logger.WriteLine("An error occured while loading: " + name);
|
||||||
else
|
else
|
||||||
Settings.Variables.outputStream.WriteLine("[CMD] Failed to load command : " + name + " because " + exception!.Message);
|
Logger.WriteLine("[CMD] Failed to load command : " + name + " because " + exception!.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = cc;
|
Console.ForegroundColor = cc;
|
||||||
@@ -115,12 +115,12 @@ public class ConsoleCommandsHandler
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Settings.Variables.outputStream.WriteLine("[EVENT] Successfully loaded event : " + name);
|
Logger.WriteLine("[EVENT] Successfully loaded event : " + name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Settings.Variables.outputStream.WriteLine("[EVENT] Failed to load event : " + name + " because " + exception!.Message);
|
Logger.WriteLine("[EVENT] Failed to load event : " + name + " because " + exception!.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = cc;
|
Console.ForegroundColor = cc;
|
||||||
@@ -134,12 +134,12 @@ public class ConsoleCommandsHandler
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Settings.Variables.outputStream.WriteLine("[SLASH] Successfully loaded command : " + name);
|
Logger.WriteLine("[SLASH] Successfully loaded command : " + name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Settings.Variables.outputStream.WriteLine("[SLASH] Failed to load command : " + name + " because " + exception!.Message);
|
Logger.WriteLine("[SLASH] Failed to load command : " + name + " because " + exception!.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = cc;
|
Console.ForegroundColor = cc;
|
||||||
@@ -159,7 +159,7 @@ public class ConsoleCommandsHandler
|
|||||||
if (args.Length == 1)
|
if (args.Length == 1)
|
||||||
{
|
{
|
||||||
isDownloading = false;
|
isDownloading = false;
|
||||||
Settings.Variables.outputStream.WriteLine("Please specify plugin name");
|
Logger.WriteLine("Please specify plugin name");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,13 +202,13 @@ public class ConsoleCommandsHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine("\n");
|
Logger.WriteLine("\n");
|
||||||
|
|
||||||
// check requirements if any
|
// check requirements if any
|
||||||
|
|
||||||
if (info.Length == 3 && info[2] != string.Empty && info[2] != null)
|
if (info.Length == 3 && info[2] != string.Empty && info[2] != null)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine($"Downloading requirements for plugin : {name}");
|
Logger.WriteLine($"Downloading requirements for plugin : {name}");
|
||||||
|
|
||||||
var lines = await ServerCom.ReadTextFromURL(info[2]);
|
var lines = await ServerCom.ReadTextFromURL(info[2]);
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ public class ConsoleCommandsHandler
|
|||||||
if (!(line.Length > 0 && line.Contains(",")))
|
if (!(line.Length > 0 && line.Contains(",")))
|
||||||
continue;
|
continue;
|
||||||
var split = line.Split(',');
|
var split = line.Split(',');
|
||||||
Settings.Variables.outputStream.WriteLine($"\nDownloading item: {split[1]}");
|
Logger.WriteLine($"\nDownloading item: {split[1]}");
|
||||||
if (File.Exists("./" + split[1])) File.Delete("./" + split[1]);
|
if (File.Exists("./" + split[1])) File.Delete("./" + split[1]);
|
||||||
if (OperatingSystem.WINDOWS == Functions.GetOperatingSystem())
|
if (OperatingSystem.WINDOWS == Functions.GetOperatingSystem())
|
||||||
{
|
{
|
||||||
@@ -231,26 +231,26 @@ public class ConsoleCommandsHandler
|
|||||||
bar.Stop("Item downloaded !");
|
bar.Stop("Item downloaded !");
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
if (split[0].EndsWith(".pak"))
|
if (split[0].EndsWith(".pak"))
|
||||||
{
|
{
|
||||||
File.Move("./" + split[1], "./Data/PAKS/" + split[1], true);
|
File.Move("./" + split[1], "./Data/PAKS/" + split[1], true);
|
||||||
}
|
}
|
||||||
else if (split[0].EndsWith(".zip") || split[0].EndsWith(".pkg"))
|
else if (split[0].EndsWith(".zip") || split[0].EndsWith(".pkg"))
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine($"Extracting {split[1]} ...");
|
Logger.WriteLine($"Extracting {split[1]} ...");
|
||||||
var bar = new Utilities.ProgressBar(
|
var bar = new Utilities.ProgressBar(
|
||||||
ProgressBarType.NO_END);
|
ProgressBarType.NO_END);
|
||||||
bar.Start();
|
bar.Start();
|
||||||
await Functions.ExtractArchive("./" + split[1], "./", null,
|
await Functions.ExtractArchive("./" + split[1], "./", null,
|
||||||
UnzipProgressType.PercentageFromTotalSize);
|
UnzipProgressType.PercentageFromTotalSize);
|
||||||
bar.Stop("Extracted");
|
bar.Stop("Extracted");
|
||||||
Settings.Variables.outputStream.WriteLine("\n");
|
Logger.WriteLine("\n");
|
||||||
File.Delete("./" + split[1]);
|
File.Delete("./" + split[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ver = await ServerCom.GetVersionOfPackageFromWeb(name);
|
var ver = await ServerCom.GetVersionOfPackageFromWeb(name);
|
||||||
@@ -272,7 +272,7 @@ public class ConsoleCommandsHandler
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var data = Config.Variables.GetValue(args[1]);
|
var data = Config.Variables.GetValue(args[1]);
|
||||||
Settings.Variables.outputStream.WriteLine($"{args[1]} => {data}");
|
Logger.WriteLine($"{args[1]} => {data}");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -287,11 +287,11 @@ public class ConsoleCommandsHandler
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Config.Variables.Add(key, value, isReadOnly);
|
Config.Variables.Add(key, value, isReadOnly);
|
||||||
Settings.Variables.outputStream.WriteLine($"Updated config file with the following command: {args[1]} => {value}");
|
Logger.WriteLine($"Updated config file with the following command: {args[1]} => {value}");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine(ex.ToString());
|
Logger.WriteLine(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -335,7 +335,7 @@ public class ConsoleCommandsHandler
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine(ex.Message);
|
Logger.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ public class ConsoleCommandsHandler
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine(ex.Message);
|
Logger.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -385,13 +385,13 @@ public class ConsoleCommandsHandler
|
|||||||
|
|
||||||
if (!File.Exists(location))
|
if (!File.Exists(location))
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine("The plugin does not exist");
|
Logger.WriteLine("The plugin does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File.Delete(location);
|
File.Delete(location);
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine("Removed the plugin DLL. Checking for other files ...");
|
Logger.WriteLine("Removed the plugin DLL. Checking for other files ...");
|
||||||
|
|
||||||
var info = await manager.GetPluginLinkByName(plugName);
|
var info = await manager.GetPluginLinkByName(plugName);
|
||||||
if (info[2] != string.Empty)
|
if (info[2] != string.Empty)
|
||||||
@@ -406,7 +406,7 @@ public class ConsoleCommandsHandler
|
|||||||
File.Delete("./" + split[1]);
|
File.Delete("./" + split[1]);
|
||||||
|
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine("Removed: " + split[1]);
|
Logger.WriteLine("Removed: " + split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Directory.Exists($"./Data/Plugins/{plugName}"))
|
if (Directory.Exists($"./Data/Plugins/{plugName}"))
|
||||||
@@ -417,7 +417,7 @@ public class ConsoleCommandsHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
isDownloading = false;
|
isDownloading = false;
|
||||||
Settings.Variables.outputStream.WriteLine(plugName + " has been successfully deleted !");
|
Logger.WriteLine(plugName + " has been successfully deleted !");
|
||||||
});
|
});
|
||||||
|
|
||||||
AddCommand("reload", "Reload the bot with all plugins", () =>
|
AddCommand("reload", "Reload the bot with all plugins", () =>
|
||||||
@@ -491,17 +491,17 @@ public class ConsoleCommandsHandler
|
|||||||
{
|
{
|
||||||
Console.SetCursorPosition(0, Console.CursorTop - 1);
|
Console.SetCursorPosition(0, Console.CursorTop - 1);
|
||||||
for (var i = 0; i < command.Length + 30; i++)
|
for (var i = 0; i < command.Length + 30; i++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Console.SetCursorPosition(0, Console.CursorTop);
|
Console.SetCursorPosition(0, Console.CursorTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
item.Action(args);
|
item.Action(args);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
//Settings.Variables.outputStream.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}");
|
//Logger.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public class PluginLoader
|
|||||||
SlashCommands = new List<DBSlashCommand>();
|
SlashCommands = new List<DBSlashCommand>();
|
||||||
|
|
||||||
Functions.WriteLogFile("Starting plugin loader ... Client: " + _client.CurrentUser.Username);
|
Functions.WriteLogFile("Starting plugin loader ... Client: " + _client.CurrentUser.Username);
|
||||||
Settings.Variables.outputStream.WriteLine("Loading plugins");
|
Logger.WriteLine("Loading plugins");
|
||||||
|
|
||||||
var loader = new LoaderV2("./Data/Plugins", "dll");
|
var loader = new LoaderV2("./Data/Plugins", "dll");
|
||||||
loader.FileLoaded += (args) => Functions.WriteLogFile($"{args.PluginName} file Loaded");
|
loader.FileLoaded += (args) => Functions.WriteLogFile($"{args.PluginName} file Loaded");
|
||||||
@@ -125,10 +125,10 @@ public class PluginLoader
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine(ex.ToString());
|
Logger.WriteLine(ex.ToString());
|
||||||
Settings.Variables.outputStream.WriteLine("Plugin: " + args.PluginName);
|
Logger.WriteLine("Plugin: " + args.PluginName);
|
||||||
Settings.Variables.outputStream.WriteLine("Type: " + args.TypeName);
|
Logger.WriteLine("Type: " + args.TypeName);
|
||||||
Settings.Variables.outputStream.WriteLine("IsLoaded: " + args.IsLoaded);
|
Logger.WriteLine("IsLoaded: " + args.IsLoaded);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "DBSlashCommand":
|
case "DBSlashCommand":
|
||||||
@@ -158,13 +158,13 @@ public class PluginLoader
|
|||||||
var instance = (DBEvent)Activator.CreateInstance(type);
|
var instance = (DBEvent)Activator.CreateInstance(type);
|
||||||
instance.Start(client);
|
instance.Start(client);
|
||||||
PluginLoader.Events.Add(instance);
|
PluginLoader.Events.Add(instance);
|
||||||
Settings.Variables.outputStream.WriteLine($"[EVENT] Loaded external {type.FullName}!");
|
Logger.WriteLine($"[EVENT] Loaded external {type.FullName}!");
|
||||||
}
|
}
|
||||||
else if (type.IsClass && typeof(DBCommand).IsAssignableFrom(type))
|
else if (type.IsClass && typeof(DBCommand).IsAssignableFrom(type))
|
||||||
{
|
{
|
||||||
var instance = (DBCommand)Activator.CreateInstance(type);
|
var instance = (DBCommand)Activator.CreateInstance(type);
|
||||||
PluginLoader.Commands.Add(instance);
|
PluginLoader.Commands.Add(instance);
|
||||||
Settings.Variables.outputStream.WriteLine($"[CMD] Instance: {type.FullName} loaded !");
|
Logger.WriteLine($"[CMD] Instance: {type.FullName} loaded !");
|
||||||
}
|
}
|
||||||
else if (type.IsClass && typeof(DBSlashCommand).IsAssignableFrom(type))
|
else if (type.IsClass && typeof(DBSlashCommand).IsAssignableFrom(type))
|
||||||
{
|
{
|
||||||
@@ -177,7 +177,7 @@ public class PluginLoader
|
|||||||
|
|
||||||
await client.CreateGlobalApplicationCommandAsync(builder.Build());
|
await client.CreateGlobalApplicationCommandAsync(builder.Build());
|
||||||
PluginLoader.SlashCommands.Add(instance);
|
PluginLoader.SlashCommands.Add(instance);
|
||||||
Settings.Variables.outputStream.WriteLine($"[SLASH] Instance: {type.FullName} loaded !");
|
Logger.WriteLine($"[SLASH] Instance: {type.FullName} loaded !");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
65
PluginManager/Logger.cs
Normal file
65
PluginManager/Logger.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace PluginManager
|
||||||
|
{
|
||||||
|
public static class Logger
|
||||||
|
{
|
||||||
|
|
||||||
|
public static bool isConsole = true;
|
||||||
|
|
||||||
|
|
||||||
|
public delegate void LogEventHandler(string Message);
|
||||||
|
public static event LogEventHandler LogEvent;
|
||||||
|
|
||||||
|
public static void Log(string Message)
|
||||||
|
{
|
||||||
|
LogEvent?.Invoke(Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Log(string Message, params object[] Args)
|
||||||
|
{
|
||||||
|
LogEvent?.Invoke(string.Format(Message, Args));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Log(IMessage message, bool newLine)
|
||||||
|
{
|
||||||
|
LogEvent?.Invoke(message.Content);
|
||||||
|
if (newLine)
|
||||||
|
LogEvent?.Invoke("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLine(string? message)
|
||||||
|
{
|
||||||
|
if (message is not null)
|
||||||
|
LogEvent?.Invoke(message + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogError(System.Exception ex)
|
||||||
|
{
|
||||||
|
string message = "[ERROR]" + ex.Message;
|
||||||
|
LogEvent?.Invoke(message + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogError(string? message)
|
||||||
|
{
|
||||||
|
if (message is not null)
|
||||||
|
LogEvent?.Invoke("[ERROR]" + message + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void WriteLine()
|
||||||
|
{
|
||||||
|
LogEvent?.Invoke("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Write(string message)
|
||||||
|
{
|
||||||
|
LogEvent?.Invoke(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Write(char c)
|
||||||
|
{
|
||||||
|
LogEvent?.Invoke($"{c}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.IO;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
|
|
||||||
namespace PluginManager.Online.Helpers;
|
namespace PluginManager.Online.Helpers;
|
||||||
@@ -18,10 +19,10 @@ internal static class OnlineFunctions
|
|||||||
/// <param name="progress">The <see cref="IProgress{T}" /> that is used to track the download progress</param>
|
/// <param name="progress">The <see cref="IProgress{T}" /> that is used to track the download progress</param>
|
||||||
/// <param name="cancellation">The cancellation token</param>
|
/// <param name="cancellation">The cancellation token</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static async Task DownloadFileAsync(this HttpClient client, string url, Stream destination,
|
internal static async Task DownloadFileAsync(this HttpClient client, string url, Stream destination,
|
||||||
IProgress<float>? progress = null,
|
IProgress<float>? progress = null,
|
||||||
IProgress<long>? downloadedBytes = null, int bufferSize = 81920,
|
IProgress<long>? downloadedBytes = null, int bufferSize = 81920,
|
||||||
CancellationToken cancellation = default)
|
CancellationToken cancellation = default)
|
||||||
{
|
{
|
||||||
using (var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, cancellation))
|
using (var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, cancellation))
|
||||||
{
|
{
|
||||||
@@ -40,14 +41,14 @@ internal static class OnlineFunctions
|
|||||||
// Convert absolute progress (bytes downloaded) into relative progress (0% - 100%)
|
// Convert absolute progress (bytes downloaded) into relative progress (0% - 100%)
|
||||||
var relativeProgress = new Progress<long>(totalBytes =>
|
var relativeProgress = new Progress<long>(totalBytes =>
|
||||||
{
|
{
|
||||||
progress.Report((float)totalBytes / contentLength.Value * 100);
|
progress?.Report((float)totalBytes / contentLength.Value * 100);
|
||||||
downloadedBytes?.Report(totalBytes);
|
downloadedBytes?.Report(totalBytes);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Use extension method to report progress while downloading
|
// Use extension method to report progress while downloading
|
||||||
await download.CopyToOtherStreamAsync(destination, bufferSize, relativeProgress, cancellation);
|
await download.CopyToOtherStreamAsync(destination, bufferSize, relativeProgress, cancellation);
|
||||||
progress.Report(1);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class PluginsManager
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine("Failed to execute command: listplugs\nReason: " + exception.Message);
|
Logger.WriteLine("Failed to execute command: listplugs\nReason: " + exception.Message);
|
||||||
Functions.WriteErrFile(exception.ToString());
|
Functions.WriteErrFile(exception.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ public class PluginsManager
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine("Failed to execute command: listplugs\nReason: " + exception.Message);
|
Logger.WriteLine("Failed to execute command: listplugs\nReason: " + exception.Message);
|
||||||
Functions.WriteErrFile(exception.ToString());
|
Functions.WriteErrFile(exception.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class PluginUpdater
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Logger.LogError(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,38 +46,38 @@ public static class Utilities
|
|||||||
foreach (var row in data)
|
foreach (var row in data)
|
||||||
{
|
{
|
||||||
if (row[0][0] == tableLine)
|
if (row[0][0] == tableLine)
|
||||||
Settings.Variables.outputStream.Write(tableCross);
|
Logger.Write(tableCross);
|
||||||
else
|
else
|
||||||
Settings.Variables.outputStream.Write(tableWall);
|
Logger.Write(tableWall);
|
||||||
for (var l = 0; l < row.Length; l++)
|
for (var l = 0; l < row.Length; l++)
|
||||||
{
|
{
|
||||||
if (row[l][0] == tableLine)
|
if (row[l][0] == tableLine)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < len[l] + 4; ++i)
|
for (var i = 0; i < len[l] + 4; ++i)
|
||||||
Settings.Variables.outputStream.Write(tableLine);
|
Logger.Write(tableLine);
|
||||||
}
|
}
|
||||||
else if (row[l].Length == len[l])
|
else if (row[l].Length == len[l])
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write(row[l]);
|
Logger.Write(row[l]);
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var lenHalf = row[l].Length / 2;
|
var lenHalf = row[l].Length / 2;
|
||||||
for (var i = 0; i < (len[l] + 4) / 2 - lenHalf; ++i)
|
for (var i = 0; i < (len[l] + 4) / 2 - lenHalf; ++i)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write(row[l]);
|
Logger.Write(row[l]);
|
||||||
for (var i = (len[l] + 4) / 2 + lenHalf + 1; i < len[l] + 4; ++i)
|
for (var i = (len[l] + 4) / 2 + lenHalf + 1; i < len[l] + 4; ++i)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
if (row[l].Length % 2 == 0)
|
if (row[l].Length % 2 == 0)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.Write(row[l][0] == tableLine ? tableCross : tableWall);
|
Logger.Write(row[l][0] == tableLine ? tableCross : tableWall);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine(); //end line
|
Logger.WriteLine(); //end line
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -95,44 +95,44 @@ public static class Utilities
|
|||||||
|
|
||||||
foreach (var row in data)
|
foreach (var row in data)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.Write("\t");
|
Logger.Write("\t");
|
||||||
if (row[0] == "-")
|
if (row[0] == "-")
|
||||||
Settings.Variables.outputStream.Write("+");
|
Logger.Write("+");
|
||||||
else
|
else
|
||||||
Settings.Variables.outputStream.Write("|");
|
Logger.Write("|");
|
||||||
|
|
||||||
foreach (var s in row)
|
foreach (var s in row)
|
||||||
{
|
{
|
||||||
if (s == "-")
|
if (s == "-")
|
||||||
{
|
{
|
||||||
for (var i = 0; i < maxLen + 4; ++i)
|
for (var i = 0; i < maxLen + 4; ++i)
|
||||||
Settings.Variables.outputStream.Write("-");
|
Logger.Write("-");
|
||||||
}
|
}
|
||||||
else if (s.Length == maxLen)
|
else if (s.Length == maxLen)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write(s);
|
Logger.Write(s);
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var lenHalf = s.Length / 2;
|
var lenHalf = s.Length / 2;
|
||||||
for (var i = 0; i < div - lenHalf; ++i)
|
for (var i = 0; i < div - lenHalf; ++i)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write(s);
|
Logger.Write(s);
|
||||||
for (var i = div + lenHalf + 1; i < maxLen + 4; ++i)
|
for (var i = div + lenHalf + 1; i < maxLen + 4; ++i)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
if (s.Length % 2 == 0)
|
if (s.Length % 2 == 0)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s == "-")
|
if (s == "-")
|
||||||
Settings.Variables.outputStream.Write("+");
|
Logger.Write("+");
|
||||||
else
|
else
|
||||||
Settings.Variables.outputStream.Write("|");
|
Logger.Write("|");
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine(); //end line
|
Logger.WriteLine(); //end line
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -153,12 +153,12 @@ public static class Utilities
|
|||||||
{
|
{
|
||||||
if (data[i][j] == "-")
|
if (data[i][j] == "-")
|
||||||
data[i][j] = " ";
|
data[i][j] = " ";
|
||||||
Settings.Variables.outputStream.Write(data[i][j]);
|
Logger.Write(data[i][j]);
|
||||||
for (var k = 0; k < widths[j] - data[i][j].Length + 1 + space_between_columns; k++)
|
for (var k = 0; k < widths[j] - data[i][j].Length + 1 + space_between_columns; k++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -169,12 +169,15 @@ public static class Utilities
|
|||||||
|
|
||||||
public static void WriteColorText(string text, bool appendNewLineAtEnd = true)
|
public static void WriteColorText(string text, bool appendNewLineAtEnd = true)
|
||||||
{
|
{
|
||||||
if (Console.Out != Settings.Variables.outputStream)
|
if (!Logger.isConsole)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.Write(text);
|
foreach (var item in Colors)
|
||||||
|
text = text.Replace($"{ColorPrefix}{item.Key}", "").Replace("&c", "");
|
||||||
|
Logger.Write(text);
|
||||||
if (appendNewLineAtEnd)
|
if (appendNewLineAtEnd)
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
var initialForeGround = Console.ForegroundColor;
|
var initialForeGround = Console.ForegroundColor;
|
||||||
var input = text.ToCharArray();
|
var input = text.ToCharArray();
|
||||||
@@ -197,12 +200,12 @@ public static class Utilities
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.Write(input[i]);
|
Logger.Write(input[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = initialForeGround;
|
Console.ForegroundColor = initialForeGround;
|
||||||
if (appendNewLineAtEnd)
|
if (appendNewLineAtEnd)
|
||||||
Settings.Variables.outputStream.WriteLine();
|
Logger.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,7 +222,7 @@ public static class Utilities
|
|||||||
|
|
||||||
public ProgressBar(ProgressBarType type)
|
public ProgressBar(ProgressBarType type)
|
||||||
{
|
{
|
||||||
if (Settings.Variables.outputStream != Console.Out)
|
if (!Logger.isConsole)
|
||||||
throw new Exception("This class (or function) can be used with console only. For UI please use another approach.");
|
throw new Exception("This class (or function) can be used with console only. For UI please use another approach.");
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
@@ -281,9 +284,9 @@ public static class Utilities
|
|||||||
{
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.CursorLeft = 0;
|
||||||
for (var i = 0; i < BarLength + message.Length + 1; i++)
|
for (var i = 0; i < BarLength + message.Length + 1; i++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Console.CursorLeft = 0;
|
Console.CursorLeft = 0;
|
||||||
Settings.Variables.outputStream.WriteLine(message);
|
Logger.WriteLine(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,14 +301,14 @@ public static class Utilities
|
|||||||
private void UpdateNoEnd(string message)
|
private void UpdateNoEnd(string message)
|
||||||
{
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.CursorLeft = 0;
|
||||||
Settings.Variables.outputStream.Write("[");
|
Logger.Write("[");
|
||||||
for (var i = 1; i <= position; i++)
|
for (var i = 1; i <= position; i++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write("<==()==>");
|
Logger.Write("<==()==>");
|
||||||
position += positive ? 1 : -1;
|
position += positive ? 1 : -1;
|
||||||
for (var i = position; i <= BarLength - 1 - (positive ? 0 : 2); i++)
|
for (var i = position; i <= BarLength - 1 - (positive ? 0 : 2); i++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write("] " + message);
|
Logger.Write("] " + message);
|
||||||
|
|
||||||
|
|
||||||
if (position == BarLength - 1 || position == 1)
|
if (position == BarLength - 1 || position == 1)
|
||||||
@@ -315,14 +318,14 @@ public static class Utilities
|
|||||||
private void UpdateNoEnd()
|
private void UpdateNoEnd()
|
||||||
{
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.CursorLeft = 0;
|
||||||
Settings.Variables.outputStream.Write("[");
|
Logger.Write("[");
|
||||||
for (var i = 1; i <= position; i++)
|
for (var i = 1; i <= position; i++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write("<==()==>");
|
Logger.Write("<==()==>");
|
||||||
position += positive ? 1 : -1;
|
position += positive ? 1 : -1;
|
||||||
for (var i = position; i <= BarLength - 1 - (positive ? 0 : 2); i++)
|
for (var i = position; i <= BarLength - 1 - (positive ? 0 : 2); i++)
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
Settings.Variables.outputStream.Write("]");
|
Logger.Write("]");
|
||||||
|
|
||||||
|
|
||||||
if (position == BarLength - 1 || position == 1)
|
if (position == BarLength - 1 || position == 1)
|
||||||
@@ -332,9 +335,9 @@ public static class Utilities
|
|||||||
private void UpdateNormal(float progress)
|
private void UpdateNormal(float progress)
|
||||||
{
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.CursorLeft = 0;
|
||||||
Settings.Variables.outputStream.Write("[");
|
Logger.Write("[");
|
||||||
Console.CursorLeft = BarLength;
|
Console.CursorLeft = BarLength;
|
||||||
Settings.Variables.outputStream.Write("]");
|
Logger.Write("]");
|
||||||
Console.CursorLeft = 1;
|
Console.CursorLeft = 1;
|
||||||
var onechunk = 30.0f / Max;
|
var onechunk = 30.0f / Max;
|
||||||
|
|
||||||
@@ -344,22 +347,22 @@ public static class Utilities
|
|||||||
{
|
{
|
||||||
Console.BackgroundColor = NoColor ? ConsoleColor.Black : Color;
|
Console.BackgroundColor = NoColor ? ConsoleColor.Black : Color;
|
||||||
Console.CursorLeft = position++;
|
Console.CursorLeft = position++;
|
||||||
Settings.Variables.outputStream.Write("#");
|
Logger.Write("#");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = position; i < BarLength; i++)
|
for (var i = position; i < BarLength; i++)
|
||||||
{
|
{
|
||||||
Console.BackgroundColor = NoColor ? ConsoleColor.Black : ConsoleColor.DarkGray;
|
Console.BackgroundColor = NoColor ? ConsoleColor.Black : ConsoleColor.DarkGray;
|
||||||
Console.CursorLeft = position++;
|
Console.CursorLeft = position++;
|
||||||
Settings.Variables.outputStream.Write(" ");
|
Logger.Write(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.CursorLeft = BarLength + 4;
|
Console.CursorLeft = BarLength + 4;
|
||||||
Console.BackgroundColor = ConsoleColor.Black;
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
if (progress.CanAproximateTo(Max))
|
if (progress.CanAproximateTo(Max))
|
||||||
Settings.Variables.outputStream.Write(progress + " % ✓");
|
Logger.Write(progress + " % ✓");
|
||||||
else
|
else
|
||||||
Settings.Variables.outputStream.Write(MathF.Round(progress, 2) + " % ");
|
Logger.Write(MathF.Round(progress, 2) + " % ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ public static class Functions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine($"Failed to extract {entry.Name}. Exception: {ex.Message}");
|
Logger.WriteLine($"Failed to extract {entry.Name}. Exception: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentZIPFile++;
|
currentZIPFile++;
|
||||||
@@ -224,7 +224,7 @@ public static class Functions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Settings.Variables.outputStream.WriteLine($"Failed to extract {entry.Name}. Exception: {ex.Message}");
|
Logger.WriteLine($"Failed to extract {entry.Name}. Exception: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.IO;
|
using PluginManager.Database;
|
||||||
|
|
||||||
using PluginManager.Database;
|
|
||||||
|
|
||||||
namespace PluginManager
|
namespace PluginManager
|
||||||
{
|
{
|
||||||
@@ -11,8 +9,6 @@ namespace PluginManager
|
|||||||
{
|
{
|
||||||
public static string WebsiteURL = "https://wizzy69.github.io/SethDiscordBot";
|
public static string WebsiteURL = "https://wizzy69.github.io/SethDiscordBot";
|
||||||
public static string UpdaterURL = "https://github.com/Wizzy69/installer/releases/download/release-1-discordbot/Updater.zip";
|
public static string UpdaterURL = "https://github.com/Wizzy69/installer/releases/download/release-1-discordbot/Updater.zip";
|
||||||
|
|
||||||
public static TextWriter outputStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SqlDatabase sqlDatabase;
|
public static SqlDatabase sqlDatabase;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlashCommands", "..\Discord
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LevelingSystem", "..\DiscordBotItems\Plugins\LevelingSystem\LevelingSystem.csproj", "{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LevelingSystem", "..\DiscordBotItems\Plugins\LevelingSystem\LevelingSystem.csproj", "{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordBotUI", "..\DiscordBotItems\DiscordBotUI\DiscordBotUI.csproj", "{3202CE21-BB39-452E-9B0C-740528CAFE43}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -39,6 +41,10 @@ Global
|
|||||||
{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0138F343-BBB9-4D5F-B499-D9C2978BE9AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3202CE21-BB39-452E-9B0C-740528CAFE43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3202CE21-BB39-452E-9B0C-740528CAFE43}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3202CE21-BB39-452E-9B0C-740528CAFE43}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3202CE21-BB39-452E-9B0C-740528CAFE43}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user