diff --git a/BUILDS/net6.0/PluginManager.dll b/BUILDS/net6.0/PluginManager.dll
index 3fb7ae6..8dcb898 100644
Binary files a/BUILDS/net6.0/PluginManager.dll and b/BUILDS/net6.0/PluginManager.dll differ
diff --git a/DiscordBot/Discord/Commands/Help.cs b/DiscordBot/Discord/Commands/Help.cs
index dbe8527..0944c6a 100644
--- a/DiscordBot/Discord/Commands/Help.cs
+++ b/DiscordBot/Discord/Commands/Help.cs
@@ -5,6 +5,7 @@ using Discord;
using Discord.Commands;
using Discord.WebSocket;
+using PluginManager;
using PluginManager.Interfaces;
using PluginManager.Loaders;
using PluginManager.Others;
@@ -42,9 +43,6 @@ internal class Help : DBCommand
/// The main body of the command
///
/// The command context
- /// The command message
- /// The discord bot client
- /// True if the message was sent from a DM channel, false otherwise
public void ExecuteServer(SocketCommandContext context)
{
var args = Functions.GetArguments(context.Message);
@@ -86,7 +84,7 @@ internal class Help : DBCommand
var cmd = PluginLoader.Commands!.Find(p => p.Command == command || (p.Aliases is not null && p.Aliases.Contains(command)));
if (cmd == null) return null;
- embedBuilder.AddField("Usage", cmd.Usage);
+ embedBuilder.AddField("Usage", Config.GetValue("prefix") + cmd.Usage);
embedBuilder.AddField("Description", cmd.Description);
if (cmd.Aliases is null)
return embedBuilder;
diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj
index 91c42bb..7ac8e4a 100644
--- a/DiscordBot/DiscordBot.csproj
+++ b/DiscordBot/DiscordBot.csproj
@@ -8,7 +8,7 @@
False
True
- 1.0.0.11
+ 1.0.0.12
diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs
index 1ec9773..e0e4ced 100644
--- a/DiscordBot/Program.cs
+++ b/DiscordBot/Program.cs
@@ -32,10 +32,6 @@ public class Program
public static void Main(string[] args)
{
Console.WriteLine("Loading resources ...");
-
- Directory.CreateDirectory("./Data/Resources");
- Directory.CreateDirectory("./Data/Plugins/Commands");
- Directory.CreateDirectory("./Data/Plugins/Events");
PreLoadComponents().Wait();
do
{
@@ -225,23 +221,6 @@ public class Program
return;
}
- if (len > 0 && args[0] == "/test")
- {
- int p = 1;
- bool allowed = true;
- Console.CancelKeyPress += (sender, e) => allowed = false;
- Console_Utilities.ProgressBar bar = new(ProgressBarType.NO_END);// { NoColor = false, Color = ConsoleColor.DarkRed };
- Console.WriteLine("Press Ctrl + C to stop.");
- while (p <= int.MaxValue - 1 && allowed)
- {
- bar.Update(100 / p);
- await Task.Delay(100);
- p++;
- }
-
- return;
- }
-
if (len > 0 && (args.Contains("--cmd") || args.Contains("--args") || args.Contains("--nomessage")))
{
if (args.Contains("lp") || args.Contains("loadplugins"))
@@ -267,6 +246,13 @@ public class Program
len = 0;
}
+ if (len > 0 && args[0] == "/updateplug")
+ {
+ string plugName = args.MergeStrings(1);
+ Console.WriteLine("Updating " + plugName);
+ await ConsoleCommandsHandler.ExecuteCommad("dwplug" + plugName);
+ return;
+ }
if (len == 0 || (args[0] != "--exec" && args[0] != "--execute"))
{
@@ -348,6 +334,10 @@ public class Program
{
Console_Utilities.ProgressBar main = new Console_Utilities.ProgressBar(ProgressBarType.NO_END);
main.Start();
+ Directory.CreateDirectory("./Data/Resources");
+ Directory.CreateDirectory("./Data/Plugins/Commands");
+ Directory.CreateDirectory("./Data/Plugins/Events");
+ Directory.CreateDirectory("./Data/PAKS");
await Config.LoadConfig();
if (Config.ContainsKey("DeleteLogsAtStartup"))
if (Config.GetValue("DeleteLogsAtStartup"))
diff --git a/FreeGamesModule/Commands.cs b/FreeGamesModule/Commands.cs
index 3382125..0571a50 100644
--- a/FreeGamesModule/Commands.cs
+++ b/FreeGamesModule/Commands.cs
@@ -12,7 +12,7 @@ namespace FreeGamesModule
public string Description => "Check out any free game";
- public string Usage => "free";
+ public string Usage => "free [platform]";
public bool requireAdmin => false;
diff --git a/PluginManager/Config.cs b/PluginManager/Config.cs
index 348602f..9f484a1 100644
--- a/PluginManager/Config.cs
+++ b/PluginManager/Config.cs
@@ -184,6 +184,11 @@ namespace PluginManager
SaveConfig(SaveType.NORMAL);
}
+ public static bool IsReadOnly(string key)
+ {
+ return appConfig.ProtectedKeyWords.Contains(key);
+ }
+
public static async Task SaveConfig(SaveType type)
{
if (type == SaveType.NORMAL)
@@ -229,6 +234,6 @@ namespace PluginManager
public static bool ContainsValue(T value) => appConfig!.ApplicationVariables!.ContainsValue(value!);
public static bool ContainsKey(string key) => appConfig!.ApplicationVariables!.ContainsKey(key);
- public static ReadOnlyDictionary GetAllVariables() => new(appConfig!.ApplicationVariables!);
+ public static IDictionary GetAllVariables() => appConfig.ApplicationVariables;
}
}
diff --git a/PluginManager/Items/ConsoleCommandsHandler.cs b/PluginManager/Items/ConsoleCommandsHandler.cs
index 3f2d455..9632db7 100644
--- a/PluginManager/Items/ConsoleCommandsHandler.cs
+++ b/PluginManager/Items/ConsoleCommandsHandler.cs
@@ -164,11 +164,10 @@ public class ConsoleCommandsHandler
path = $"./{info[1].Split('/')[info[1].Split('/').Length - 1]}";
//Console.WriteLine("Downloading: " + path + " [" + info[1] + "]");
await ServerCom.DownloadFileAsync(info[1], path);
- if (info[0] == "Command" || info[0] == "Event")
- if (info[0] == "Event")
- Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Event));
- else if (info[0] == "Command")
- Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Command));
+ if (info[0] == "Event")
+ Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Event));
+ else if (info[0] == "Command")
+ Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Command));
Console.WriteLine("\n");
@@ -190,11 +189,12 @@ public class ConsoleCommandsHandler
if (File.Exists("./" + split[1])) File.Delete("./" + split[1]);
await ServerCom.DownloadFileAsync(split[0], "./" + split[1]);
Console.WriteLine();
-
- if (split[0].EndsWith(".zip") || split[0].EndsWith(".pak") || split[0].EndsWith(".pkg"))
+ if (split[0].EndsWith(".pak"))
+ File.Move("./" + split[1], "./Data/PAKS/" + split[1], true);
+ else if (split[0].EndsWith(".zip") || split[0].EndsWith(".pkg"))
{
Console.WriteLine($"Extracting {split[1]} ...");
- var bar = new Console_Utilities.ProgressBar(ProgressBarType.NO_END) { Max = 100f, Color = ConsoleColor.Green };
+ var bar = new Console_Utilities.ProgressBar(ProgressBarType.NO_END);// { Max = 100f, Color = ConsoleColor.Green };
bar.Start();
await Functions.ExtractArchive("./" + split[1], "./", null, UnzipProgressType.PercentageFromTotalSize);
bar.Stop();
diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs
index 7934d29..f512f1e 100644
--- a/PluginManager/Others/Functions.cs
+++ b/PluginManager/Others/Functions.cs
@@ -50,21 +50,42 @@ namespace PluginManager.Others
/// The file name that is inside the archive or its full path
/// The archive location from the PAKs folder
/// A string that represents the content of the file or null if the file does not exists or it has no content
- public static async Task ReadFromPakAsync(string FileName, string archFile)
+ public static async Task ReadFromPakAsync(string FileName, string archFile)
{
archFile = pakFolder + archFile;
- Directory.CreateDirectory(pakFolder);
- if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
+ if (!File.Exists(archFile))
+ throw new Exception("Failed to load file !");
- using ZipArchive archive = ZipFile.OpenRead(archFile);
- ZipArchiveEntry? entry = archive.GetEntry(FileName);
- if (entry is null) return Stream.Null;
- MemoryStream stream = new MemoryStream();
- await (entry?.Open()!).CopyToAsync(stream);
+ try
+ {
+ string textValue = null;
+ using (var fs = new FileStream(archFile, FileMode.Open))
+ using (var zip = new ZipArchive(fs, ZipArchiveMode.Read))
+ foreach (var entry in zip.Entries)
+ {
+ if (entry.Name == FileName || entry.FullName == FileName)
+ {
+ using (Stream s = entry.Open())
+ using (StreamReader reader = new StreamReader(s))
+ {
+ textValue = await reader.ReadToEndAsync();
+ reader.Close();
+ s.Close();
+ fs.Close();
+ }
+ }
+ }
+ return textValue;
+ }
+ catch
+ {
+ await Task.Delay(100);
+ return await ReadFromPakAsync(FileName, archFile);
+ }
- return stream;
}
+
///
/// Write logs to file
///
diff --git a/SethDiscordBot.sln b/SethDiscordBot.sln
index f8bfc8d..7d57f4b 100644
--- a/SethDiscordBot.sln
+++ b/SethDiscordBot.sln
@@ -27,7 +27,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Others", "Others", "{727BBA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "Updater\Updater.csproj", "{24616F7E-E2E9-45A3-8A44-AB51FCD2D525}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeGamesModule", "FreeGamesModule\FreeGamesModule.csproj", "{8959C766-414D-4EF8-BC85-9928B30AAF0A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeGamesModule", "FreeGamesModule\FreeGamesModule.csproj", "{8959C766-414D-4EF8-BC85-9928B30AAF0A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBotWindowsUI", "DiscordBotWindowsUI\DiscordBotWindowsUI.csproj", "{EFE12083-F9FE-4807-8E39-809E0391BAF0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsUI", "WindowsUI\WindowsUI.csproj", "{ECF79CD3-789E-476D-8512-CE0FAF71ADF5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -71,6 +75,14 @@ Global
{8959C766-414D-4EF8-BC85-9928B30AAF0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8959C766-414D-4EF8-BC85-9928B30AAF0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8959C766-414D-4EF8-BC85-9928B30AAF0A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EFE12083-F9FE-4807-8E39-809E0391BAF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EFE12083-F9FE-4807-8E39-809E0391BAF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EFE12083-F9FE-4807-8E39-809E0391BAF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EFE12083-F9FE-4807-8E39-809E0391BAF0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ECF79CD3-789E-476D-8512-CE0FAF71ADF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ECF79CD3-789E-476D-8512-CE0FAF71ADF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ECF79CD3-789E-476D-8512-CE0FAF71ADF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ECF79CD3-789E-476D-8512-CE0FAF71ADF5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -86,6 +98,7 @@ Global
{727BBA0B-9114-4BC8-B9A8-3F461449A564} = {1862ABD5-7C30-4F15-A561-45AC8A9CA10E}
{24616F7E-E2E9-45A3-8A44-AB51FCD2D525} = {727BBA0B-9114-4BC8-B9A8-3F461449A564}
{8959C766-414D-4EF8-BC85-9928B30AAF0A} = {449FA364-0B72-43FF-B3A3-806E2916200E}
+ {ECF79CD3-789E-476D-8512-CE0FAF71ADF5} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}