This commit is contained in:
Wizzy69
2022-05-06 08:57:37 +03:00
parent d2c1cdab77
commit 7fcdf7db56
7 changed files with 16 additions and 40 deletions

Binary file not shown.

View File

@@ -9,11 +9,10 @@ using PluginManager.Others;
using PluginManager.Loaders; using PluginManager.Loaders;
using PluginManager.LanguageSystem; using PluginManager.LanguageSystem;
using PluginManager.Online; using PluginManager.Online;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
namespace DiscordBot namespace DiscordBot
{ {
public class Program public class Program
@@ -37,7 +36,7 @@ namespace DiscordBot
Directory.CreateDirectory("./Data/Languages"); Directory.CreateDirectory("./Data/Languages");
Directory.CreateDirectory("./Data/Plugins/Commands"); Directory.CreateDirectory("./Data/Plugins/Commands");
Directory.CreateDirectory("./Data/Plugins/Events"); Directory.CreateDirectory("./Data/Plugins/Events");
if (!File.Exists("./Data/Resources/DiscordBotCore.data") || Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", '=')!.Length != 59) if (!File.Exists("./Data/Resources/DiscordBotCore.data") || (Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", '=').Length != 59 && Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", '=').Length != 70))
{ {
File.WriteAllText("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN=token\nBOT_PREFIX=!\n"); File.WriteAllText("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN=token\nBOT_PREFIX=!\n");
while (true) while (true)
@@ -45,7 +44,7 @@ namespace DiscordBot
Console.WriteLine("Please insert your token: "); Console.WriteLine("Please insert your token: ");
Console.Write("TOKEN: "); Console.Write("TOKEN: ");
string botToken = Console.ReadLine(); string botToken = Console.ReadLine();
if (botToken.Length == 59) if (botToken.Length == 59 || botToken.Length == 70)
{ {
string prefix = Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", '='); string prefix = Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", '=');
if (prefix == string.Empty || prefix == null) if (prefix == string.Empty || prefix == null)
@@ -96,7 +95,9 @@ namespace DiscordBot
Console_Utilities.WriteColorText("&mConsole > &c", false); Console_Utilities.WriteColorText("&mConsole > &c", false);
string[] data = Console.ReadLine().Split(' '); string[] data = Console.ReadLine().Split(' ');
if (data[0].Length < 2) continue; if (data[0].Length < 2)
continue; // The input command is less then 2 characters long
switch (data[0]) switch (data[0])
{ {
case "shutdown": case "shutdown":

View File

@@ -61,7 +61,11 @@ namespace PluginManager.Loaders
Functions.WriteLogFile("Starting plugin loader..."); Functions.WriteLogFile("Starting plugin loader...");
if (LanguageSystem.Language.ActiveLanguage != null) if (LanguageSystem.Language.ActiveLanguage != null)
Console_Utilities.WriteColorText(LanguageSystem.Language.ActiveLanguage.FormatText(LanguageSystem.Language.ActiveLanguage.LanguageWords["PLUGIN_LOADING_START"])); Console_Utilities.WriteColorText(
LanguageSystem.Language.ActiveLanguage.FormatText(
LanguageSystem.Language.ActiveLanguage.LanguageWords["PLUGIN_LOADING_START"]
)
);
//Load commands //Load commands
CommandsLoader CMDLoader = new CommandsLoader(pluginCMDFolder, pluginCMDExtension); CommandsLoader CMDLoader = new CommandsLoader(pluginCMDFolder, pluginCMDExtension);

View File

@@ -27,11 +27,6 @@ namespace PluginManager.Online
try try
{ {
/*#pragma warning disable SYSLIB0014
WebClient client = new WebClient();
#pragma warning restore SYSLIB0014
Stream data = await client.OpenReadTaskAsync(link);
string[] lines = (await new StreamReader(data).ReadToEndAsync()).Split('\n');*/
List<string> list = await ServerCom.ReadTextFromFile(link); List<string> list = await ServerCom.ReadTextFromFile(link);
string[] lines = list.ToArray(); string[] lines = list.ToArray();

View File

@@ -63,7 +63,7 @@ namespace PluginManager.Online
continue; continue;
} }
} }
else if (op == PluginManager.Others.OperatingSystem.LINUX) else if (op == Others.OperatingSystem.LINUX)
{ {
if (content[4].Contains("Linux")) if (content[4].Contains("Linux"))
{ {

View File

@@ -57,11 +57,8 @@ namespace PluginManager.Online
bool isDownloading = true; bool isDownloading = true;
int c_progress = 0; int c_progress = 0;
long secondsPast = 0; //long m_dwBytes = 0;
long m_dwBytes = 0;
double c_downloadSpeed = 0f;
string c_downloadUnit = "MB";
Others.Console_Utilities.ProgressBar pbar = new Others.Console_Utilities.ProgressBar(100, ""); Others.Console_Utilities.ProgressBar pbar = new Others.Console_Utilities.ProgressBar(100, "");
IProgress<float> progress = new Progress<float>(percent => IProgress<float> progress = new Progress<float>(percent =>
@@ -71,39 +68,20 @@ namespace PluginManager.Online
IProgress<long> progress_downloaded = new Progress<long>(downloadedBytes => IProgress<long> progress_downloaded = new Progress<long>(downloadedBytes =>
{ {
m_dwBytes = downloadedBytes; //m_dwBytes = downloadedBytes;
}); });
Task updateProgressBarTask = new Task(async () => Task updateProgressBarTask = new Task(async () =>
{ {
while (isDownloading) while (isDownloading)
{ {
//pbar.Update(c_progress, c_downloadSpeed, c_downloadUnit);
pbar.Update(c_progress); pbar.Update(c_progress);
if (c_progress == 100) if (c_progress == 100)
break; break;
System.Threading.Thread.Sleep(500); System.Threading.Thread.Sleep(500);
} }
}); });
Task calculateDownloadSpeed = new Task(async () =>
{
while (isDownloading)
{
secondsPast++;
c_downloadSpeed = m_dwBytes / secondsPast;
c_downloadSpeed /= 1024; // in KB
c_downloadSpeed /= 1024; // in MB
c_downloadSpeed = Math.Round(c_downloadSpeed, 2, MidpointRounding.AwayFromZero);
System.Threading.Thread.Sleep(1000);
}
});
// new System.Threading.Thread(calculateDownloadSpeed.Start).Start();
new System.Threading.Thread(updateProgressBarTask.Start).Start(); new System.Threading.Thread(updateProgressBarTask.Start).Start();
await DownloadFileAsync(URL, location, progress, progress_downloaded); await DownloadFileAsync(URL, location, progress, progress_downloaded);

View File

@@ -96,7 +96,6 @@ namespace PluginManager.Others
foreach (string[] row in data) foreach (string[] row in data)
{ {
//Console.Write("\t");
if (row[0][0] == tableLine) Console.Write(tableCross); if (row[0][0] == tableLine) Console.Write(tableCross);
else Console.Write(tableWall); else Console.Write(tableWall);
for (int l = 0; l < row.Length; l++) for (int l = 0; l < row.Length; l++)
@@ -135,7 +134,6 @@ namespace PluginManager.Others
/// <summary> /// <summary>
/// Write the text using color options( &g-green; &b-blue; &r-red; &c-clear; ) /// Write the text using color options( &g-green; &b-blue; &r-red; &c-clear; )
///
/// </summary> /// </summary>
/// <param name="text">The text</param> /// <param name="text">The text</param>
public static void WriteColorText(string text, bool appendNewLine = true) public static void WriteColorText(string text, bool appendNewLine = true)