Code formatting and renamed DBCommandExecutingArguments to DbCommandExecutingArguments
This commit is contained in:
@@ -141,7 +141,7 @@ internal class CommandHandler
|
||||
if (split.Length > 1)
|
||||
argsClean = string.Join(' ', split, 1, split.Length - 1).Split(' ');
|
||||
|
||||
DBCommandExecutingArguments cmd = new(context, cleanMessage, split[0], argsClean);
|
||||
DbCommandExecutingArguments cmd = new(context, cleanMessage, split[0], argsClean);
|
||||
|
||||
Config.Logger.Log(
|
||||
message: $"User ({context.User.Username}) from Guild \"{context.Guild.Name}\" executed command \"{cmd.cleanContent}\"",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using PluginManager.Bot;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Logger;
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface DBCommand
|
||||
/// The main body of the command. This is what is executed when user calls the command in Server
|
||||
/// </summary>
|
||||
/// <param name="args">The disocrd Context</param>
|
||||
void ExecuteServer(DBCommandExecutingArguments args)
|
||||
void ExecuteServer(DbCommandExecutingArguments args)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface DBCommand
|
||||
/// The main body of the command. This is what is executed when user calls the command in DM
|
||||
/// </summary>
|
||||
/// <param name="args">The disocrd Context</param>
|
||||
void ExecuteDM(DBCommandExecutingArguments args)
|
||||
void ExecuteDM(DbCommandExecutingArguments args)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
using PluginManager.Online.Helpers;
|
||||
using PluginManager.Others;
|
||||
using OperatingSystem = PluginManager.Others.OperatingSystem;
|
||||
|
||||
namespace PluginManager.Online;
|
||||
|
||||
public class PluginsManager
|
||||
@@ -40,7 +37,6 @@ public class PluginsManager
|
||||
var lines = list.ToArray();
|
||||
|
||||
var data = new List<string[]>();
|
||||
var op = Functions.GetOperatingSystem();
|
||||
|
||||
var len = lines.Length;
|
||||
for (var i = 0; i < len; i++)
|
||||
@@ -49,7 +45,7 @@ public class PluginsManager
|
||||
continue;
|
||||
var content = lines[i].Split(',');
|
||||
var display = new string[4]; // 4 columns
|
||||
if (op == OperatingSystem.WINDOWS)
|
||||
if (System.OperatingSystem.IsWindows())
|
||||
{
|
||||
if (content[4].Contains("Windows"))
|
||||
{
|
||||
@@ -62,7 +58,7 @@ public class PluginsManager
|
||||
data.Add(display);
|
||||
}
|
||||
}
|
||||
else if (op == OperatingSystem.LINUX)
|
||||
else if (System.OperatingSystem.IsLinux())
|
||||
{
|
||||
if (content[4].Contains("Linux"))
|
||||
{
|
||||
@@ -122,7 +118,7 @@ public class PluginsManager
|
||||
var contents = lines[i].Split(',');
|
||||
if (contents[0].ToLowerInvariant() == name.ToLowerInvariant())
|
||||
{
|
||||
if (Functions.GetOperatingSystem() == OperatingSystem.WINDOWS && contents[4].Contains("Windows"))
|
||||
if (System.OperatingSystem.IsWindows() && contents[4].Contains("Windows"))
|
||||
{
|
||||
if (contents.Length == 6)
|
||||
return new[]
|
||||
@@ -138,7 +134,7 @@ public class PluginsManager
|
||||
|
||||
}
|
||||
|
||||
if (Functions.GetOperatingSystem() == OperatingSystem.LINUX && contents[4].Contains("Linux"))
|
||||
if (System.OperatingSystem.IsLinux() && contents[4].Contains("Linux"))
|
||||
{
|
||||
if (contents.Length == 6)
|
||||
return new[]
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using System.Linq;
|
||||
using Discord.Commands;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using PluginManager.Bot;
|
||||
|
||||
|
||||
namespace PluginManager.Others;
|
||||
|
||||
public class DBCommandExecutingArguments
|
||||
public class DbCommandExecutingArguments
|
||||
{
|
||||
public DBCommandExecutingArguments(
|
||||
public DbCommandExecutingArguments(
|
||||
SocketCommandContext context, string cleanContent, string commandUsed, string[]? arguments)
|
||||
{
|
||||
this.context = context;
|
||||
@@ -16,7 +15,7 @@ public class DBCommandExecutingArguments
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public DBCommandExecutingArguments(SocketUserMessage? message, DiscordSocketClient client)
|
||||
public DbCommandExecutingArguments(SocketUserMessage? message, DiscordSocketClient client)
|
||||
{
|
||||
this.context = new SocketCommandContext(client, message);
|
||||
int pos = 0;
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
namespace PluginManager.Others;
|
||||
|
||||
/// <summary>
|
||||
/// A list of operating systems
|
||||
/// </summary>
|
||||
public enum OperatingSystem
|
||||
{
|
||||
WINDOWS,
|
||||
LINUX,
|
||||
MAC_OS,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The output log type
|
||||
/// </summary>
|
||||
@@ -39,9 +28,3 @@ public enum InternalActionRunType
|
||||
ON_STARTUP,
|
||||
ON_CALL
|
||||
}
|
||||
|
||||
internal enum ExceptionExitCode: int
|
||||
{
|
||||
CONFIG_FAILED_TO_LOAD = 1,
|
||||
CONFIG_KEY_NOT_FOUND = 2,
|
||||
}
|
||||
|
||||
@@ -29,18 +29,6 @@ public static class Functions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Operating system you are runnin on
|
||||
/// </summary>
|
||||
/// <returns>An Operating system</returns>
|
||||
public static OperatingSystem GetOperatingSystem()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return OperatingSystem.WINDOWS;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return OperatingSystem.LINUX;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) return OperatingSystem.MAC_OS;
|
||||
return OperatingSystem.UNKNOWN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy one Stream to another <see langword="async" />
|
||||
/// </summary>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.6" />
|
||||
<PackageReference Include="Discord.Net" Version="3.11.0"/>
|
||||
<PackageReference Include="Spectre.Console" Version="0.47.0" />
|
||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -5,11 +5,12 @@ namespace PluginManager.UX.Linux;
|
||||
|
||||
internal class KDE : IOutputModel
|
||||
{
|
||||
internal string KdeDialogApplication { get; } = "kdialog";
|
||||
|
||||
public async Task ShowMessageBox(string title, string message, MessageBoxType type)
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "kdialog";
|
||||
process.StartInfo.FileName = KdeDialogApplication;
|
||||
|
||||
string typeStr = type switch
|
||||
{
|
||||
@@ -27,9 +28,10 @@ internal class KDE : IOutputModel
|
||||
public async Task<string> ShowInputBox(string title, string message)
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "kdialog";
|
||||
process.StartInfo.FileName = KdeDialogApplication;
|
||||
process.StartInfo.Arguments = $"--title \"{title}\" --inputbox \"{message}\"";
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardInput = true;
|
||||
process.Start();
|
||||
|
||||
await process.WaitForExitAsync();
|
||||
@@ -39,7 +41,7 @@ internal class KDE : IOutputModel
|
||||
public async Task ShowMessageBox(string message)
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "kdialog";
|
||||
process.StartInfo.FileName = KdeDialogApplication;
|
||||
process.StartInfo.Arguments = $"--msgbox \"{message}\"";
|
||||
process.Start();
|
||||
await process.WaitForExitAsync();
|
||||
@@ -48,7 +50,7 @@ internal class KDE : IOutputModel
|
||||
public async Task<int> ShowMessageBox(string title, string message, MessageBoxButtons buttons, bool isWarning)
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "kdialog";
|
||||
process.StartInfo.FileName = KdeDialogApplication;
|
||||
|
||||
string buttonsStr = buttons switch
|
||||
{
|
||||
@@ -67,7 +69,7 @@ internal class KDE : IOutputModel
|
||||
public async Task ShowNotification(string title, string message, int timeout_seconds = 5)
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "kdialog";
|
||||
process.StartInfo.FileName = KdeDialogApplication;
|
||||
process.StartInfo.Arguments = $"--title \"{title}\" --passivepopup \"{message}\" {timeout_seconds}";
|
||||
process.Start();
|
||||
await process.WaitForExitAsync();
|
||||
|
||||
@@ -19,33 +19,29 @@ internal class Console : IOutputModel
|
||||
|
||||
public Task<string> ShowInputBox(string title, string message)
|
||||
{
|
||||
AnsiConsole.Markup(title);
|
||||
AnsiConsole.Markup(message);
|
||||
AnsiConsole.MarkupLine(title);
|
||||
|
||||
string input = AnsiConsole.Ask<string>("Please enter the value:");
|
||||
string input = AnsiConsole.Ask<string>(message);
|
||||
|
||||
return Task.FromResult(input);
|
||||
}
|
||||
|
||||
public Task ShowMessageBox(string message)
|
||||
{
|
||||
AnsiConsole.Markup(message);
|
||||
AnsiConsole.MarkupLine(message);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<int> ShowMessageBox(string title, string message,MessageBoxButtons buttons, bool isWarning)
|
||||
{
|
||||
AnsiConsole.Markup(title);
|
||||
AnsiConsole.Markup(message);
|
||||
AnsiConsole.MarkupLine(title);
|
||||
AnsiConsole.MarkupLine(message);
|
||||
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
public Task ShowNotification(string title, string message, int timeout_seconds = 5)
|
||||
{
|
||||
AnsiConsole.Markup(title);
|
||||
AnsiConsole.Markup(message);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ namespace PluginManager.UX;
|
||||
|
||||
public static class UxHandler
|
||||
{
|
||||
private static IOutputModel _model;
|
||||
private static IOutputModel? _model;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_model = Config.AppSettings["UI"] switch
|
||||
{
|
||||
"KDE" => new Linux.KDE(),
|
||||
"Console" => new Other.Console(),
|
||||
_ => _model
|
||||
"CONSOLE" => new Other.Console(),
|
||||
_ => null
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user