patch
This commit is contained in:
Binary file not shown.
@@ -5,6 +5,7 @@ using Discord;
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
|
|
||||||
|
using PluginManager;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
@@ -42,9 +43,6 @@ internal class Help : DBCommand
|
|||||||
/// The main body of the command
|
/// The main body of the command
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The command context</param>
|
/// <param name="context">The command context</param>
|
||||||
/// <param name="message">The command message</param>
|
|
||||||
/// <param name="client">The discord bot client</param>
|
|
||||||
/// <param name="isDM">True if the message was sent from a DM channel, false otherwise</param>
|
|
||||||
public void ExecuteServer(SocketCommandContext context)
|
public void ExecuteServer(SocketCommandContext context)
|
||||||
{
|
{
|
||||||
var args = Functions.GetArguments(context.Message);
|
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)));
|
var cmd = PluginLoader.Commands!.Find(p => p.Command == command || (p.Aliases is not null && p.Aliases.Contains(command)));
|
||||||
if (cmd == null) return null;
|
if (cmd == null) return null;
|
||||||
|
|
||||||
embedBuilder.AddField("Usage", cmd.Usage);
|
embedBuilder.AddField("Usage", Config.GetValue<string>("prefix") + cmd.Usage);
|
||||||
embedBuilder.AddField("Description", cmd.Description);
|
embedBuilder.AddField("Description", cmd.Description);
|
||||||
if (cmd.Aliases is null)
|
if (cmd.Aliases is null)
|
||||||
return embedBuilder;
|
return embedBuilder;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<StartupObject />
|
<StartupObject />
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<IsPublishable>True</IsPublishable>
|
<IsPublishable>True</IsPublishable>
|
||||||
<AssemblyVersion>1.0.0.11</AssemblyVersion>
|
<AssemblyVersion>1.0.0.12</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ public class Program
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Loading resources ...");
|
Console.WriteLine("Loading resources ...");
|
||||||
|
|
||||||
Directory.CreateDirectory("./Data/Resources");
|
|
||||||
Directory.CreateDirectory("./Data/Plugins/Commands");
|
|
||||||
Directory.CreateDirectory("./Data/Plugins/Events");
|
|
||||||
PreLoadComponents().Wait();
|
PreLoadComponents().Wait();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -225,23 +221,6 @@ public class Program
|
|||||||
return;
|
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 (len > 0 && (args.Contains("--cmd") || args.Contains("--args") || args.Contains("--nomessage")))
|
||||||
{
|
{
|
||||||
if (args.Contains("lp") || args.Contains("loadplugins"))
|
if (args.Contains("lp") || args.Contains("loadplugins"))
|
||||||
@@ -267,6 +246,13 @@ public class Program
|
|||||||
len = 0;
|
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"))
|
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);
|
Console_Utilities.ProgressBar main = new Console_Utilities.ProgressBar(ProgressBarType.NO_END);
|
||||||
main.Start();
|
main.Start();
|
||||||
|
Directory.CreateDirectory("./Data/Resources");
|
||||||
|
Directory.CreateDirectory("./Data/Plugins/Commands");
|
||||||
|
Directory.CreateDirectory("./Data/Plugins/Events");
|
||||||
|
Directory.CreateDirectory("./Data/PAKS");
|
||||||
await Config.LoadConfig();
|
await Config.LoadConfig();
|
||||||
if (Config.ContainsKey("DeleteLogsAtStartup"))
|
if (Config.ContainsKey("DeleteLogsAtStartup"))
|
||||||
if (Config.GetValue<bool>("DeleteLogsAtStartup"))
|
if (Config.GetValue<bool>("DeleteLogsAtStartup"))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace FreeGamesModule
|
|||||||
|
|
||||||
public string Description => "Check out any free game";
|
public string Description => "Check out any free game";
|
||||||
|
|
||||||
public string Usage => "free";
|
public string Usage => "free [platform]";
|
||||||
|
|
||||||
public bool requireAdmin => false;
|
public bool requireAdmin => false;
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,11 @@ namespace PluginManager
|
|||||||
SaveConfig(SaveType.NORMAL);
|
SaveConfig(SaveType.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsReadOnly(string key)
|
||||||
|
{
|
||||||
|
return appConfig.ProtectedKeyWords.Contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task SaveConfig(SaveType type)
|
public static async Task SaveConfig(SaveType type)
|
||||||
{
|
{
|
||||||
if (type == SaveType.NORMAL)
|
if (type == SaveType.NORMAL)
|
||||||
@@ -229,6 +234,6 @@ namespace PluginManager
|
|||||||
public static bool ContainsValue<T>(T value) => appConfig!.ApplicationVariables!.ContainsValue(value!);
|
public static bool ContainsValue<T>(T value) => appConfig!.ApplicationVariables!.ContainsValue(value!);
|
||||||
public static bool ContainsKey(string key) => appConfig!.ApplicationVariables!.ContainsKey(key);
|
public static bool ContainsKey(string key) => appConfig!.ApplicationVariables!.ContainsKey(key);
|
||||||
|
|
||||||
public static ReadOnlyDictionary<string, object> GetAllVariables() => new(appConfig!.ApplicationVariables!);
|
public static IDictionary<string, object> GetAllVariables() => appConfig.ApplicationVariables;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ public class ConsoleCommandsHandler
|
|||||||
path = $"./{info[1].Split('/')[info[1].Split('/').Length - 1]}";
|
path = $"./{info[1].Split('/')[info[1].Split('/').Length - 1]}";
|
||||||
//Console.WriteLine("Downloading: " + path + " [" + info[1] + "]");
|
//Console.WriteLine("Downloading: " + path + " [" + info[1] + "]");
|
||||||
await ServerCom.DownloadFileAsync(info[1], path);
|
await ServerCom.DownloadFileAsync(info[1], path);
|
||||||
if (info[0] == "Command" || info[0] == "Event")
|
|
||||||
if (info[0] == "Event")
|
if (info[0] == "Event")
|
||||||
Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Event));
|
Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Event));
|
||||||
else if (info[0] == "Command")
|
else if (info[0] == "Command")
|
||||||
@@ -190,11 +189,12 @@ public class ConsoleCommandsHandler
|
|||||||
if (File.Exists("./" + split[1])) File.Delete("./" + split[1]);
|
if (File.Exists("./" + split[1])) File.Delete("./" + split[1]);
|
||||||
await ServerCom.DownloadFileAsync(split[0], "./" + split[1]);
|
await ServerCom.DownloadFileAsync(split[0], "./" + split[1]);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
if (split[0].EndsWith(".pak"))
|
||||||
if (split[0].EndsWith(".zip") || split[0].EndsWith(".pak") || split[0].EndsWith(".pkg"))
|
File.Move("./" + split[1], "./Data/PAKS/" + split[1], true);
|
||||||
|
else if (split[0].EndsWith(".zip") || split[0].EndsWith(".pkg"))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Extracting {split[1]} ...");
|
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();
|
bar.Start();
|
||||||
await Functions.ExtractArchive("./" + split[1], "./", null, UnzipProgressType.PercentageFromTotalSize);
|
await Functions.ExtractArchive("./" + split[1], "./", null, UnzipProgressType.PercentageFromTotalSize);
|
||||||
bar.Stop();
|
bar.Stop();
|
||||||
|
|||||||
@@ -50,20 +50,41 @@ namespace PluginManager.Others
|
|||||||
/// <param name="FileName">The file name that is inside the archive or its full path</param>
|
/// <param name="FileName">The file name that is inside the archive or its full path</param>
|
||||||
/// <param name="archFile">The archive location from the PAKs folder</param>
|
/// <param name="archFile">The archive location from the PAKs folder</param>
|
||||||
/// <returns>A string that represents the content of the file or null if the file does not exists or it has no content</returns>
|
/// <returns>A string that represents the content of the file or null if the file does not exists or it has no content</returns>
|
||||||
public static async Task<Stream?> ReadFromPakAsync(string FileName, string archFile)
|
public static async Task<string> ReadFromPakAsync(string FileName, string archFile)
|
||||||
{
|
{
|
||||||
archFile = pakFolder + archFile;
|
archFile = pakFolder + archFile;
|
||||||
Directory.CreateDirectory(pakFolder);
|
if (!File.Exists(archFile))
|
||||||
if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
|
throw new Exception("Failed to load file !");
|
||||||
|
|
||||||
using ZipArchive archive = ZipFile.OpenRead(archFile);
|
try
|
||||||
ZipArchiveEntry? entry = archive.GetEntry(FileName);
|
{
|
||||||
if (entry is null) return Stream.Null;
|
string textValue = null;
|
||||||
MemoryStream stream = new MemoryStream();
|
using (var fs = new FileStream(archFile, FileMode.Open))
|
||||||
await (entry?.Open()!).CopyToAsync(stream);
|
using (var zip = new ZipArchive(fs, ZipArchiveMode.Read))
|
||||||
|
foreach (var entry in zip.Entries)
|
||||||
return stream;
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write logs to file
|
/// Write logs to file
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Others", "Others", "{727BBA
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "Updater\Updater.csproj", "{24616F7E-E2E9-45A3-8A44-AB51FCD2D525}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "Updater\Updater.csproj", "{24616F7E-E2E9-45A3-8A44-AB51FCD2D525}"
|
||||||
EndProject
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{8959C766-414D-4EF8-BC85-9928B30AAF0A}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -86,6 +98,7 @@ Global
|
|||||||
{727BBA0B-9114-4BC8-B9A8-3F461449A564} = {1862ABD5-7C30-4F15-A561-45AC8A9CA10E}
|
{727BBA0B-9114-4BC8-B9A8-3F461449A564} = {1862ABD5-7C30-4F15-A561-45AC8A9CA10E}
|
||||||
{24616F7E-E2E9-45A3-8A44-AB51FCD2D525} = {727BBA0B-9114-4BC8-B9A8-3F461449A564}
|
{24616F7E-E2E9-45A3-8A44-AB51FCD2D525} = {727BBA0B-9114-4BC8-B9A8-3F461449A564}
|
||||||
{8959C766-414D-4EF8-BC85-9928B30AAF0A} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
{8959C766-414D-4EF8-BC85-9928B30AAF0A} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||||
|
{ECF79CD3-789E-476D-8512-CE0FAF71ADF5} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}
|
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}
|
||||||
|
|||||||
Reference in New Issue
Block a user