Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 641f0f2856 | |||
| ef5439d204 | |||
| c2093c2aca | |||
| a39f7bb0c9 | |||
| 6d73ec7f24 |
@@ -8,7 +8,7 @@
|
|||||||
<StartupObject />
|
<StartupObject />
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<IsPublishable>True</IsPublishable>
|
<IsPublishable>True</IsPublishable>
|
||||||
<AssemblyVersion>1.0.0.13</AssemblyVersion>
|
<AssemblyVersion>1.0.0.14</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -7,14 +7,16 @@ using System.Reflection;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
using DiscordBot.Discord.Core;
|
using DiscordBot.Discord.Core;
|
||||||
|
|
||||||
using PluginManager;
|
using PluginManager;
|
||||||
|
|
||||||
using PluginManager.Items;
|
using PluginManager.Items;
|
||||||
using PluginManager.Online;
|
using PluginManager.Online;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
|
|
||||||
|
using Terminal.Gui;
|
||||||
|
|
||||||
namespace DiscordBot;
|
namespace DiscordBot;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
@@ -30,70 +32,142 @@ public class Program
|
|||||||
[Obsolete]
|
[Obsolete]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine("Loading resources ...");
|
Console.WriteLine("Loading resources ...");
|
||||||
PreLoadComponents().Wait();
|
PreLoadComponents().Wait();
|
||||||
do
|
|
||||||
|
|
||||||
|
if (!Config.ContainsKey("ServerID") || (!Config.ContainsKey("token") || Config.GetValue<string>("token") == null || (Config.GetValue<string>("token")?.Length != 70 && Config.GetValue<string>("token")?.Length != 59)) || (!Config.ContainsKey("prefix") || Config.GetValue<string>("prefix") == null || Config.GetValue<string>("prefix")?.Length != 1) || (args.Length > 0 && args[0] == "/newconfig"))
|
||||||
{
|
{
|
||||||
if (!Config.ContainsKey("ServerID"))
|
Application.Init();
|
||||||
|
var top = Application.Top;
|
||||||
|
|
||||||
|
Application.IsMouseDisabled = true;
|
||||||
|
var win = new Window("Discord Bot Config - " + Assembly.GetExecutingAssembly().GetName().Version)
|
||||||
{
|
{
|
||||||
|
X = 0,
|
||||||
|
Y = 1,
|
||||||
|
Width = Dim.Fill(),
|
||||||
|
Height = Dim.Fill()
|
||||||
|
};
|
||||||
|
|
||||||
|
top.Add(win);
|
||||||
|
|
||||||
|
var labelInfo = new Label("Configuration file not found or invalid. Please fill the following fields to create a new configuration file.")
|
||||||
|
{
|
||||||
|
X = Pos.Center(),
|
||||||
|
Y = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("Please enter the server ID: ");
|
var labelToken = new Label("Please insert your token here: ")
|
||||||
Console_Utilities.WriteColorText("You can find it in the Server Settings at &r\"Widget\"&c section");
|
{
|
||||||
Console.WriteLine("Example: 1234567890123456789");
|
X = 5,
|
||||||
|
Y = 5
|
||||||
|
};
|
||||||
|
|
||||||
Console.WriteLine("This is not required, but is recommended. If you refuse to provide the ID, just press enter.\nThe server id is required to make easier for the bot to interact with the server.\nRemember: this bot is for one server ONLY.");
|
var textFiledToken = new TextField("")
|
||||||
Console.Write("User Input > ");
|
{
|
||||||
ConsoleKeyInfo key = Console.ReadKey();
|
X = Pos.Left(labelToken) + labelToken.Text.Length + 2,
|
||||||
if (key.Key == ConsoleKey.Enter)
|
Y = labelToken.Y,
|
||||||
Config.AddValueToVariables("ServerID", "null", false);
|
Width = 70
|
||||||
else
|
};
|
||||||
|
|
||||||
|
var labelPrefix = new Label("Please insert your prefix here: ")
|
||||||
|
{
|
||||||
|
X = 5,
|
||||||
|
Y = 8
|
||||||
|
};
|
||||||
|
var textFiledPrefix = new TextField("")
|
||||||
|
{
|
||||||
|
X = Pos.Left(labelPrefix) + labelPrefix.Text.Length + 2,
|
||||||
|
Y = labelPrefix.Y,
|
||||||
|
Width = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
var labelServerid = new Label("Please insert your server id here (optional): ")
|
||||||
|
{
|
||||||
|
X = 5,
|
||||||
|
Y = 11,
|
||||||
|
|
||||||
|
};
|
||||||
|
var textFiledServerID = new TextField("null")
|
||||||
|
{
|
||||||
|
X = Pos.Left(labelServerid) + labelServerid.Text.Length + 2,
|
||||||
|
Y = labelServerid.Y,
|
||||||
|
Width = 18
|
||||||
|
};
|
||||||
|
|
||||||
|
var button = new Button("Submit")
|
||||||
|
{
|
||||||
|
X = Pos.Center() - 10,
|
||||||
|
Y = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
var button2 = new Button("License")
|
||||||
|
{
|
||||||
|
X = Pos.Center() + 10,
|
||||||
|
Y = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
Console.CancelKeyPress += (sender, e) =>
|
||||||
|
{
|
||||||
|
top.Running = false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
button.Clicked += () =>
|
||||||
|
{
|
||||||
|
string passMessage = "";
|
||||||
|
if (textFiledToken.Text.Length != 70 && textFiledToken.Text.Length != 59)
|
||||||
|
passMessage += "Invalid token, ";
|
||||||
|
if (textFiledPrefix.Text.ContainsAny("0123456789/\\ ") || textFiledPrefix.Text.Length != 1)
|
||||||
|
passMessage += "Invalid prefix, ";
|
||||||
|
if (textFiledServerID.Text.Length != 18 && textFiledServerID.Text.Length > 0)
|
||||||
|
passMessage += "Invalid serverID";
|
||||||
|
|
||||||
|
if (passMessage != "")
|
||||||
{
|
{
|
||||||
string SID = key.KeyChar + Console.ReadLine();
|
MessageBox.ErrorQuery("Discord Bot Settings", "Failed to pass check. Invalid information given:\n" + passMessage, "Retry");
|
||||||
if (SID.Length != 18)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Config.AddValueToVariables<string>("ServerID", ((string)textFiledServerID.Text), true);
|
||||||
|
Config.AddValueToVariables<string>("token", ((string)textFiledToken.Text), true);
|
||||||
|
Config.AddValueToVariables<string>("prefix", ((string)textFiledPrefix.Text), true);
|
||||||
|
|
||||||
|
MessageBox.Query("Discord Bot Settings", "Successfully saved config !\nJust start the bot :D", "Start :D");
|
||||||
|
top.Running = false;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
button2.Clicked += async () =>
|
||||||
|
{
|
||||||
|
string[] license = await File.ReadAllLinesAsync("LICENSE.txt");
|
||||||
|
string ProductLicense = "Seth Discord Bot\n\nDeveloped by Wizzy#9181\nThis application can be used and modified by anyone. Plugin development for this application is also free and supported";
|
||||||
|
int r = MessageBox.Query("Discord Bot Settings", ProductLicense, "Close", "Read about libraries used");
|
||||||
|
if (r == 1)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (i < license.Length)
|
||||||
{
|
{
|
||||||
Console.Clear();
|
string print_message = license[i++] + "\n";
|
||||||
Console_Utilities.WriteColorText("&rYour server ID is not 18 characters long. Please try again. \n");
|
for (; i < license.Length && !license[i].StartsWith("-----------"); i++)
|
||||||
|
print_message += license[i] + "\n";
|
||||||
continue;
|
if (MessageBox.Query("Licenses", print_message, "Next", "Quit") == 1) break;
|
||||||
}
|
}
|
||||||
Config.AddValueToVariables("ServerID", SID, false);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if (!Config.ContainsKey("token") || Config.GetValue<string>("token") == null || (Config.GetValue<string>("token")?.Length != 70 && Config.GetValue<string>("token")?.Length != 59))
|
win.Add(labelInfo, labelPrefix, labelServerid, labelToken);
|
||||||
{
|
win.Add(textFiledToken, textFiledPrefix, textFiledServerID);
|
||||||
Console.WriteLine("Please insert your token");
|
win.Add(button, button2);
|
||||||
Console.Write("Token = ");
|
Application.Run();
|
||||||
var token = Console.ReadLine();
|
Application.Shutdown();
|
||||||
if (token?.Length == 59 || token?.Length == 70)
|
}
|
||||||
Config.AddValueToVariables("token", token, true);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.Clear();
|
|
||||||
Console_Utilities.WriteColorText("&rThe token length is invalid !");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Config.ContainsKey("prefix") || Config.GetValue<string>("prefix") == null || Config.GetValue<string>("prefix")?.Length != 1)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Please insert your prefix (max. 1 character long):");
|
|
||||||
Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces, numbers, '/' or '\\' allowed");
|
|
||||||
Console.Write("Prefix = ");
|
|
||||||
var prefix = Console.ReadLine()![0];
|
|
||||||
|
|
||||||
if (prefix == ' ' || char.IsDigit(prefix) || prefix == '/' || prefix == '\\')
|
|
||||||
{
|
|
||||||
Console.Clear();
|
|
||||||
Console_Utilities.WriteColorText("&rThe prefix is invalid");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
} while (true);
|
|
||||||
|
|
||||||
HandleInput(args).Wait();
|
HandleInput(args).Wait();
|
||||||
}
|
}
|
||||||
@@ -230,6 +304,11 @@ public class Program
|
|||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len == 2 && args[0] == "/procKill")
|
||||||
|
{
|
||||||
|
Process.GetProcessById(int.Parse(args[1])).Kill();
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var b = await StartNoGUI();
|
var b = await StartNoGUI();
|
||||||
@@ -370,7 +449,7 @@ public class Program
|
|||||||
|
|
||||||
|
|
||||||
List<string> onlineSettingsList = await ServerCom.ReadTextFromURL("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/OnlineData");
|
List<string> onlineSettingsList = await ServerCom.ReadTextFromURL("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/OnlineData");
|
||||||
main.Stop();
|
main.Stop("Loaded online settings. Loading updates ...");
|
||||||
foreach (var key in onlineSettingsList)
|
foreach (var key in onlineSettingsList)
|
||||||
{
|
{
|
||||||
if (key.Length <= 3 || !key.Contains(' ')) continue;
|
if (key.Length <= 3 || !key.Contains(' ')) continue;
|
||||||
@@ -394,15 +473,19 @@ public class Program
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string url = $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip";
|
string url = $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip";
|
||||||
Process.Start("./Updater/Updater", $"/update {url} ./DiscordBot ./");
|
Console.WriteLine("Downloading update ...");
|
||||||
|
await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip");
|
||||||
|
await File.WriteAllTextAsync("Install.sh", "#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot");
|
||||||
|
Process.Start("Install.sh").WaitForExit();
|
||||||
|
Environment.Exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
//Environment.Exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "UpdaterVersion":
|
case "UpdaterVersion":
|
||||||
string updaternewversion = s[1];
|
string updaternewversion = s[1];
|
||||||
if (Config.UpdaterVersion != updaternewversion)
|
if (Config.UpdaterVersion != updaternewversion && Functions.GetOperatingSystem() == PluginManager.Others.OperatingSystem.WINDOWS)
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.WriteLine("Installing updater ...\nDo NOT close the bot during update !");
|
Console.WriteLine("Installing updater ...\nDo NOT close the bot during update !");
|
||||||
@@ -413,7 +496,7 @@ public class Program
|
|||||||
Config.UpdaterVersion = updaternewversion;
|
Config.UpdaterVersion = updaternewversion;
|
||||||
File.Delete("Updater.zip");
|
File.Delete("Updater.zip");
|
||||||
await Config.SaveConfig(SaveType.NORMAL);
|
await Config.SaveConfig(SaveType.NORMAL);
|
||||||
bar.Stop();
|
bar.Stop("Updater has been updated !");
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ using PluginManager.Interfaces;
|
|||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
using PluginManager.Online;
|
using PluginManager.Online;
|
||||||
using PluginManager.Online.Helpers;
|
using PluginManager.Online.Helpers;
|
||||||
using PluginManager.Online.Updates;
|
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
|
|
||||||
namespace PluginManager.Items;
|
namespace PluginManager.Items;
|
||||||
|
|
||||||
public class ConsoleCommandsHandler
|
public class ConsoleCommandsHandler
|
||||||
@@ -162,8 +160,18 @@ public class ConsoleCommandsHandler
|
|||||||
path = "./Data/Plugins/" + info[0] + "s/" + name + "." + (info[0] == "Command" ? PluginLoader.pluginCMDExtension : PluginLoader.pluginEVEExtension);
|
path = "./Data/Plugins/" + info[0] + "s/" + name + "." + (info[0] == "Command" ? PluginLoader.pluginCMDExtension : PluginLoader.pluginEVEExtension);
|
||||||
else
|
else
|
||||||
path = $"./{info[1].Split('/')[info[1].Split('/').Length - 1]}";
|
path = $"./{info[1].Split('/')[info[1].Split('/').Length - 1]}";
|
||||||
//Console.WriteLine("Downloading: " + path + " [" + info[1] + "]");
|
if (Others.OperatingSystem.WINDOWS == Functions.GetOperatingSystem())
|
||||||
await ServerCom.DownloadFileAsync(info[1], path);
|
{
|
||||||
|
await ServerCom.DownloadFileAsync(info[1], path);
|
||||||
|
}
|
||||||
|
else if (Others.OperatingSystem.LINUX == Functions.GetOperatingSystem())
|
||||||
|
{
|
||||||
|
Others.Console_Utilities.ProgressBar bar = new Console_Utilities.ProgressBar(ProgressBarType.NO_END);
|
||||||
|
bar.Start();
|
||||||
|
await ServerCom.DownloadFileNoProgressAsync(info[1], path);
|
||||||
|
bar.Stop("Plugin Downloaded !");
|
||||||
|
}
|
||||||
|
|
||||||
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")
|
||||||
@@ -187,7 +195,16 @@ public class ConsoleCommandsHandler
|
|||||||
var split = line.Split(',');
|
var split = line.Split(',');
|
||||||
Console.WriteLine($"\nDownloading item: {split[1]}");
|
Console.WriteLine($"\nDownloading item: {split[1]}");
|
||||||
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]);
|
if (Others.OperatingSystem.WINDOWS == Functions.GetOperatingSystem())
|
||||||
|
await ServerCom.DownloadFileAsync(split[0], "./" + split[1]);
|
||||||
|
else if (Others.OperatingSystem.LINUX == Functions.GetOperatingSystem())
|
||||||
|
{
|
||||||
|
Others.Console_Utilities.ProgressBar bar = new Console_Utilities.ProgressBar(ProgressBarType.NO_END);
|
||||||
|
bar.Start();
|
||||||
|
await ServerCom.DownloadFileNoProgressAsync(split[0], "./" + split[1]);
|
||||||
|
bar.Stop("Item downloaded !");
|
||||||
|
|
||||||
|
}
|
||||||
Console.WriteLine();
|
Console.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);
|
||||||
@@ -197,7 +214,7 @@ public class ConsoleCommandsHandler
|
|||||||
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("Extracted");
|
||||||
Console.WriteLine("\n");
|
Console.WriteLine("\n");
|
||||||
File.Delete("./" + split[1]);
|
File.Delete("./" + split[1]);
|
||||||
}
|
}
|
||||||
@@ -208,10 +225,12 @@ public class ConsoleCommandsHandler
|
|||||||
VersionString? ver = await VersionString.GetVersionOfPackageFromWeb(name);
|
VersionString? ver = await VersionString.GetVersionOfPackageFromWeb(name);
|
||||||
if (ver is null) throw new Exception("Incorrect version");
|
if (ver is null) throw new Exception("Incorrect version");
|
||||||
Config.SetPluginVersion(name, $"{ver.PackageVersionID}.{ver.PackageMainVersion}.{ver.PackageCheckVersion}");
|
Config.SetPluginVersion(name, $"{ver.PackageVersionID}.{ver.PackageMainVersion}.{ver.PackageCheckVersion}");
|
||||||
// Console.WriteLine();
|
|
||||||
|
|
||||||
isDownloading = false;
|
isDownloading = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -264,11 +283,12 @@ public class ConsoleCommandsHandler
|
|||||||
bar.Start();
|
bar.Start();
|
||||||
await Config.SaveConfig(SaveType.NORMAL);
|
await Config.SaveConfig(SaveType.NORMAL);
|
||||||
await Config.SaveConfig(SaveType.BACKUP);
|
await Config.SaveConfig(SaveType.BACKUP);
|
||||||
await Task.Delay(4000);
|
bar.Stop("Saved config !");
|
||||||
bar.Stop();
|
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
await client.StopAsync();
|
await client.StopAsync();
|
||||||
await client.DisposeAsync();
|
await client.DisposeAsync();
|
||||||
|
|
||||||
|
await Task.Delay(1000);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,15 @@ namespace PluginManager.Others
|
|||||||
public bool NoColor { get; init; }
|
public bool NoColor { get; init; }
|
||||||
public ProgressBarType type { get; set; }
|
public ProgressBarType type { get; set; }
|
||||||
|
|
||||||
|
public int TotalLength { get; private set; }
|
||||||
|
|
||||||
private int BarLength = 32;
|
private int BarLength = 32;
|
||||||
private int position = 1;
|
private int position = 1;
|
||||||
private bool positive = true;
|
private bool positive = true;
|
||||||
|
|
||||||
private bool isRunning;
|
private bool isRunning;
|
||||||
|
|
||||||
|
|
||||||
public async void Start()
|
public async void Start()
|
||||||
{
|
{
|
||||||
if (type != ProgressBarType.NO_END)
|
if (type != ProgressBarType.NO_END)
|
||||||
@@ -63,6 +66,23 @@ namespace PluginManager.Others
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void Start(string message)
|
||||||
|
{
|
||||||
|
if (type != ProgressBarType.NO_END)
|
||||||
|
throw new Exception("Only NO_END progress bar can use this method");
|
||||||
|
if (isRunning)
|
||||||
|
throw new Exception("This progress bar is already running");
|
||||||
|
|
||||||
|
isRunning = true;
|
||||||
|
|
||||||
|
TotalLength = message.Length + BarLength + 5;
|
||||||
|
while (isRunning)
|
||||||
|
{
|
||||||
|
UpdateNoEnd(message);
|
||||||
|
await System.Threading.Tasks.Task.Delay(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
if (type != ProgressBarType.NO_END)
|
if (type != ProgressBarType.NO_END)
|
||||||
@@ -72,20 +92,45 @@ namespace PluginManager.Others
|
|||||||
isRunning = false;
|
isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Stop(string message)
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
|
||||||
|
if (message is not null)
|
||||||
|
{
|
||||||
|
Console.CursorLeft = 0;
|
||||||
|
for (int i = 0; i < BarLength + message.Length + 1; i++)
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.CursorLeft = 0;
|
||||||
|
Console.WriteLine(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Update(float progress)
|
public void Update(float progress)
|
||||||
{
|
{
|
||||||
switch (type)
|
if (type == ProgressBarType.NO_END)
|
||||||
{
|
throw new Exception("This function is for progress bars with end");
|
||||||
case ProgressBarType.NORMAL:
|
|
||||||
UpdateNormal(progress);
|
UpdateNormal(progress);
|
||||||
return;
|
}
|
||||||
case ProgressBarType.NO_END:
|
|
||||||
if (progress <= 99.9f)
|
private void UpdateNoEnd(string message)
|
||||||
UpdateNoEnd();
|
{
|
||||||
return;
|
Console.CursorLeft = 0;
|
||||||
default:
|
Console.Write("[");
|
||||||
return;
|
for (int i = 1; i <= position; i++)
|
||||||
}
|
Console.Write(" ");
|
||||||
|
Console.Write("<==()==>");
|
||||||
|
position += positive ? 1 : -1;
|
||||||
|
for (int i = position; i <= BarLength - 1 - (positive ? 0 : 2); i++)
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.Write("] " + message);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (position == BarLength - 1 || position == 1)
|
||||||
|
positive = !positive;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateNoEnd()
|
private void UpdateNoEnd()
|
||||||
@@ -101,6 +146,8 @@ namespace PluginManager.Others
|
|||||||
Console.Write("]");
|
Console.Write("]");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (position == BarLength - 1 || position == 1)
|
if (position == BarLength - 1 || position == 1)
|
||||||
positive = !positive;
|
positive = !positive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Net" Version="3.7.2" />
|
<PackageReference Include="Discord.Net" Version="3.7.2" />
|
||||||
|
<PackageReference Include="Terminal.Gui" Version="1.8.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user