From 0a77abb854198c6b5325a3ce672941e0393902ba Mon Sep 17 00:00:00 2001 From: Wizzy69 Date: Sun, 15 May 2022 10:53:29 +0300 Subject: [PATCH] --- BUILDS/net6.0/StartupEvents.dll | Bin 12800 -> 12800 bytes DiscordBot/Discord/Commands/Restart.cs | 4 ++-- DiscordBot/Program.cs | 11 +++++---- PluginManager/Online/PluginsManager.cs | 2 +- PluginManager/Others/Console Utilities.cs | 15 +----------- PluginManager/Others/Enums.cs | 2 +- PluginManager/Others/Functions.cs | 2 +- StartupEvents/OnUserJoin.cs | 4 +--- TODO | 27 ++++++++++++++++++++++ 9 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 TODO diff --git a/BUILDS/net6.0/StartupEvents.dll b/BUILDS/net6.0/StartupEvents.dll index 49ec2e1c448093020589e93f0b86653da8d8b598..c289609ec6f5af27cb7480f0b36a16c567c12531 100644 GIT binary patch delta 589 zcmX|8L1+^}6#Z}9>}KN<>sDxmz|6#vuO>- z_$x2FV2Uz#^tf^!(0g0)cs>->9 z4t176zqW|)^Iz(6bgHJhWOvq9YF1NWYLMUZyJsh4kJUO=VM)nONm=T&nl#liWd5J_ z`giH_E^Tj{;6MFO;PD4$9IyCma~&()ceRX1738FpAcT5u=38`|*cq*JKfdts<- zM$C8IM{krid?k2@;{yKBU(J;0N`Z-Q`ZOBoVRJCCYV=E-)aIq_qTR$e|89??Aci|X z1;v$~x0-yQ)#pq7&6N|y=4dgqmit^1ZnA)odC;!EWA?B;CGMpXnnr*S osRrzm?eA9ZONz(5_#x!Q4W|MA#>tCddTS3G>l6FkAMjk`ANQ++8vpXZd&P2 z{diHx2k}W^@i-1J#11uf1R%)5q?3(c2R>uB@MfzmFu9~5pu%(%pd11~b~)P3ljNF$ zyVwey!v%IyOOD1fQ3{u=ZU85cTqA%&axS5(Q~{t@dIWy4R|ek)yp(LMPUte_x>M*T zYVEE?n*YbGK8Z%rBWY+*Rgr0q6PRYF9X_070D=26?Aw2iGbMu^qN`dyQ)mKZBCJOuLr z07)uxcsLOkw#?tT9-|R}54faINWzlhhC%Ho<$3oj+}_+S2Ux}ZWQ%x5f9*8YQc)>T zFzd0Wnmpa%w>>ksa|YW;9D`6%hp>oY9Km1kN703ji8LL*&jkZtd3(71O*mr8uC_(R progress = null; Task t; @@ -94,7 +95,7 @@ namespace DiscordBot while (true) { Console.ForegroundColor = ConsoleColor.White; - Console_Utilities.WriteColorText("&mConsole > &c", false); + Console_Utilities.WriteColorText("&mConsole ", false); string[] data = Console.ReadLine().Split(' '); if (data[0].Length < 2) @@ -150,7 +151,7 @@ namespace DiscordBot if (info.Length == 3 && info[2] != string.Empty && info[2] != null) { Console.WriteLine($"Downloading requirements for plugin : {name}"); - // + List lines = await ServerCom.ReadTextFromFile(info[2]); int i = 1; @@ -172,6 +173,7 @@ namespace DiscordBot case "setlang": if (data.Length == 2) SetLanguage(data[1]); + else Console.WriteLine("Invalid arguments"); break; case "set-setting": if (data.Length >= 3) @@ -230,7 +232,8 @@ namespace DiscordBot break; case "help": Console.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine( + Console.WriteLine + ( "lp | loadplugins -> load all plugins\n" + "sd | shutdown->close connection to the server(stop bot)\n" + "token -> display the current token\n" + @@ -308,7 +311,7 @@ namespace DiscordBot //Load language from the specified file ... Language.ActiveLanguage = null; - string langname = File.ReadAllText(langSettings).Split('=')[1]; + string langname = Functions.readCodeFromFile(langSettings, "Language", '='); if (langname == "English") { Language.ActiveLanguage = null; diff --git a/PluginManager/Online/PluginsManager.cs b/PluginManager/Online/PluginsManager.cs index 344d3fd..1e7a7e6 100644 --- a/PluginManager/Online/PluginsManager.cs +++ b/PluginManager/Online/PluginsManager.cs @@ -36,7 +36,7 @@ namespace PluginManager.Online string[] lines = list.ToArray(); List data = new List(); - var op = Functions.GetOperatinSystem(); + var op = Functions.GetOperatingSystem(); int len = lines.Length; string[] titles = { "Name", "Description", "Plugin Type", "Libraries" }; diff --git a/PluginManager/Others/Console Utilities.cs b/PluginManager/Others/Console Utilities.cs index 2d2cbf6..1cdf29a 100644 --- a/PluginManager/Others/Console Utilities.cs +++ b/PluginManager/Others/Console Utilities.cs @@ -62,15 +62,6 @@ namespace PluginManager.Others else Console.Write(progress.ToString() + $"{speed} {unit}/s "); - //if (r == false) - //Update(progress, true); - - } - - public void Finish() - { - Console.Write("\r{0} {1}%", Message, 100); - Console.WriteLine(); } } @@ -132,13 +123,9 @@ namespace PluginManager.Others } } - /// - /// Write text using colors: &g - green, &r - red, &b - blue, &m - magenta, &c - Clear - /// - /// - /// public static void WriteColorText(string text, bool appendNewLine = true) { + string[] words = text.Split(' '); ConsoleColor fg = Console.ForegroundColor; Dictionary colors = new Dictionary() diff --git a/PluginManager/Others/Enums.cs b/PluginManager/Others/Enums.cs index 5413955..222e169 100644 --- a/PluginManager/Others/Enums.cs +++ b/PluginManager/Others/Enums.cs @@ -11,7 +11,7 @@ /// A list with all errors /// public enum Error - { UNKNOWN_ERROR, GUILD_NOT_FOUND, STREAM_NOT_FOUND } + { UNKNOWN_ERROR, GUILD_NOT_FOUND, STREAM_NOT_FOUND, INVALID_USER, INVALID_CHANNEL, INVALID_PERMISSIONS } /// /// The output log type diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs index 7c5de71..a2a7d5a 100644 --- a/PluginManager/Others/Functions.cs +++ b/PluginManager/Others/Functions.cs @@ -162,7 +162,7 @@ namespace PluginManager.Others /// Get the Operating system you are runnin on /// /// An Operating system - public static OperatingSystem GetOperatinSystem() + public static OperatingSystem GetOperatingSystem() { if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) return OperatingSystem.WINDOWS; if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) return OperatingSystem.LINUX; diff --git a/StartupEvents/OnUserJoin.cs b/StartupEvents/OnUserJoin.cs index 10fbbe1..bb4ff5f 100644 --- a/StartupEvents/OnUserJoin.cs +++ b/StartupEvents/OnUserJoin.cs @@ -14,8 +14,6 @@ public class OnUserJoin : DBEvent public async void Start(Discord.WebSocket.DiscordSocketClient client) { - - System.IO.Directory.CreateDirectory(UtilsPath); if (!System.IO.File.Exists(ConfigFile)) @@ -36,7 +34,7 @@ public class OnUserJoin : DBEvent } if (Functions.readCodeFromFile(ConfigFile, "Enabled", '=') != "True") return; - System.Console.WriteLine("Awaiting user join event ..."); + //System.Console.WriteLine("Awaiting user join event ..."); client.UserJoined += Client_UserJoined; diff --git a/TODO b/TODO new file mode 100644 index 0000000..50534d2 --- /dev/null +++ b/TODO @@ -0,0 +1,27 @@ +Discord Bot: + ✔ Create bootloader + ✔ Create commands handler + +Plugin Manager: + Define plugin interface: + ✔ DBCommand + ✔ DBPlugin + + Functions.cs: + ✔ Read from file + ✔ Read from archive (PAK) + ✔ Write Logs & Errors + ✔ Manipulate settings (files) and strings + ✔ Stream copy async + + Console Utilities: + ✔ Progress bar + ✔ Create table + ✔ Write to console with colors + + Discord Permissions: + ✔ Check if user has permission + ✔ Check if user is owner + + + \ No newline at end of file