This commit is contained in:
Binary file not shown.
@@ -53,7 +53,7 @@ namespace DiscordBot.Discord.Commands
|
|||||||
{
|
{
|
||||||
if (!DiscordPermissions.hasPermission(message.Author as SocketGuildUser, DiscordLib.GuildPermission.Administrator)) return;
|
if (!DiscordPermissions.hasPermission(message.Author as SocketGuildUser, DiscordLib.GuildPermission.Administrator)) return;
|
||||||
var args = Functions.GetArguments(message);
|
var args = Functions.GetArguments(message);
|
||||||
var OS = Functions.GetOperatinSystem();
|
var OS = Functions.GetOperatingSystem();
|
||||||
if (args.Count == 0)
|
if (args.Count == 0)
|
||||||
{
|
{
|
||||||
switch (OS)
|
switch (OS)
|
||||||
@@ -94,7 +94,7 @@ namespace DiscordBot.Discord.Commands
|
|||||||
Process.Start("./DiscordBot.exe", cmd);
|
Process.Start("./DiscordBot.exe", cmd);
|
||||||
break;
|
break;
|
||||||
case PluginManager.Others.OperatingSystem.LINUX:
|
case PluginManager.Others.OperatingSystem.LINUX:
|
||||||
case PluginManager.Others.OperatingSystem.MAC_OS:
|
//case PluginManager.Others.OperatingSystem.MAC_OS: ?? - not tested
|
||||||
Process.Start("./DiscordBot", cmd);
|
Process.Start("./DiscordBot", cmd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ namespace DiscordBot
|
|||||||
if (listLanguagAtStartup)
|
if (listLanguagAtStartup)
|
||||||
await languageManager.ListAllLanguages();
|
await languageManager.ListAllLanguages();
|
||||||
|
|
||||||
|
|
||||||
Console_Utilities.ProgressBar pbar;
|
Console_Utilities.ProgressBar pbar;
|
||||||
IProgress<float> progress = null;
|
IProgress<float> progress = null;
|
||||||
Task t;
|
Task t;
|
||||||
@@ -94,7 +95,7 @@ namespace DiscordBot
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console_Utilities.WriteColorText("&mConsole > &c", false);
|
Console_Utilities.WriteColorText("&mConsole ", false);
|
||||||
string[] data = Console.ReadLine().Split(' ');
|
string[] data = Console.ReadLine().Split(' ');
|
||||||
|
|
||||||
if (data[0].Length < 2)
|
if (data[0].Length < 2)
|
||||||
@@ -150,7 +151,7 @@ namespace DiscordBot
|
|||||||
if (info.Length == 3 && info[2] != string.Empty && info[2] != null)
|
if (info.Length == 3 && info[2] != string.Empty && info[2] != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Downloading requirements for plugin : {name}");
|
Console.WriteLine($"Downloading requirements for plugin : {name}");
|
||||||
//
|
|
||||||
List<string> lines = await ServerCom.ReadTextFromFile(info[2]);
|
List<string> lines = await ServerCom.ReadTextFromFile(info[2]);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
@@ -172,6 +173,7 @@ namespace DiscordBot
|
|||||||
case "setlang":
|
case "setlang":
|
||||||
if (data.Length == 2)
|
if (data.Length == 2)
|
||||||
SetLanguage(data[1]);
|
SetLanguage(data[1]);
|
||||||
|
else Console.WriteLine("Invalid arguments");
|
||||||
break;
|
break;
|
||||||
case "set-setting":
|
case "set-setting":
|
||||||
if (data.Length >= 3)
|
if (data.Length >= 3)
|
||||||
@@ -230,7 +232,8 @@ namespace DiscordBot
|
|||||||
break;
|
break;
|
||||||
case "help":
|
case "help":
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
||||||
Console.WriteLine(
|
Console.WriteLine
|
||||||
|
(
|
||||||
"lp | loadplugins -> load all plugins\n" +
|
"lp | loadplugins -> load all plugins\n" +
|
||||||
"sd | shutdown->close connection to the server(stop bot)\n" +
|
"sd | shutdown->close connection to the server(stop bot)\n" +
|
||||||
"token -> display the current token\n" +
|
"token -> display the current token\n" +
|
||||||
@@ -308,7 +311,7 @@ namespace DiscordBot
|
|||||||
//Load language from the specified file ...
|
//Load language from the specified file ...
|
||||||
Language.ActiveLanguage = null;
|
Language.ActiveLanguage = null;
|
||||||
|
|
||||||
string langname = File.ReadAllText(langSettings).Split('=')[1];
|
string langname = Functions.readCodeFromFile(langSettings, "Language", '=');
|
||||||
if (langname == "English")
|
if (langname == "English")
|
||||||
{
|
{
|
||||||
Language.ActiveLanguage = null;
|
Language.ActiveLanguage = null;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace PluginManager.Online
|
|||||||
string[] lines = list.ToArray();
|
string[] lines = list.ToArray();
|
||||||
|
|
||||||
List<string[]> data = new List<string[]>();
|
List<string[]> data = new List<string[]>();
|
||||||
var op = Functions.GetOperatinSystem();
|
var op = Functions.GetOperatingSystem();
|
||||||
|
|
||||||
int len = lines.Length;
|
int len = lines.Length;
|
||||||
string[] titles = { "Name", "Description", "Plugin Type", "Libraries" };
|
string[] titles = { "Name", "Description", "Plugin Type", "Libraries" };
|
||||||
|
|||||||
@@ -62,15 +62,6 @@ namespace PluginManager.Others
|
|||||||
else
|
else
|
||||||
Console.Write(progress.ToString() + $"{speed} {unit}/s ");
|
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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Write text using colors: &g - green, &r - red, &b - blue, &m - magenta, &c - Clear
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text"></param>
|
|
||||||
/// <param name="appendNewLine"></param>
|
|
||||||
public static void WriteColorText(string text, bool appendNewLine = true)
|
public static void WriteColorText(string text, bool appendNewLine = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
string[] words = text.Split(' ');
|
string[] words = text.Split(' ');
|
||||||
ConsoleColor fg = Console.ForegroundColor;
|
ConsoleColor fg = Console.ForegroundColor;
|
||||||
Dictionary<string, ConsoleColor> colors = new Dictionary<string, ConsoleColor>()
|
Dictionary<string, ConsoleColor> colors = new Dictionary<string, ConsoleColor>()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/// A list with all errors
|
/// A list with all errors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum Error
|
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 }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The output log type
|
/// The output log type
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace PluginManager.Others
|
|||||||
/// Get the Operating system you are runnin on
|
/// Get the Operating system you are runnin on
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>An Operating system</returns>
|
/// <returns>An Operating system</returns>
|
||||||
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.Windows)) return OperatingSystem.WINDOWS;
|
||||||
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) return OperatingSystem.LINUX;
|
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) return OperatingSystem.LINUX;
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public class OnUserJoin : DBEvent
|
|||||||
public async void Start(Discord.WebSocket.DiscordSocketClient client)
|
public async void Start(Discord.WebSocket.DiscordSocketClient client)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.IO.Directory.CreateDirectory(UtilsPath);
|
System.IO.Directory.CreateDirectory(UtilsPath);
|
||||||
|
|
||||||
if (!System.IO.File.Exists(ConfigFile))
|
if (!System.IO.File.Exists(ConfigFile))
|
||||||
@@ -36,7 +34,7 @@ public class OnUserJoin : DBEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Functions.readCodeFromFile(ConfigFile, "Enabled", '=') != "True") return;
|
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;
|
client.UserJoined += Client_UserJoined;
|
||||||
|
|
||||||
|
|||||||
27
TODO
Normal file
27
TODO
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user