The plugin install command now automatically refreshes the installed plugins.
This commit is contained in:
@@ -15,7 +15,7 @@ public class Plugin : ICommandAction
|
|||||||
private bool pluginsLoaded;
|
private bool pluginsLoaded;
|
||||||
public string ActionName => "plugin";
|
public string ActionName => "plugin";
|
||||||
public string Description => "Manages plugins. Use plugin help for more info.";
|
public string Description => "Manages plugins. Use plugin help for more info.";
|
||||||
public string Usage => "plugin [help|list|load|install]";
|
public string Usage => "plugin [help|list|load|install|refresh]";
|
||||||
public InternalActionRunType RunType => InternalActionRunType.ON_CALL;
|
public InternalActionRunType RunType => InternalActionRunType.ON_CALL;
|
||||||
|
|
||||||
public async Task Execute(string[] args)
|
public async Task Execute(string[] args)
|
||||||
@@ -27,6 +27,7 @@ public class Plugin : ICommandAction
|
|||||||
Console.WriteLine("list : Lists all plugins");
|
Console.WriteLine("list : Lists all plugins");
|
||||||
Console.WriteLine("load : Loads all plugins");
|
Console.WriteLine("load : Loads all plugins");
|
||||||
Console.WriteLine("install : Installs a plugin");
|
Console.WriteLine("install : Installs a plugin");
|
||||||
|
Console.WriteLine("refresh : Refreshes the plugin list");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -35,6 +36,9 @@ public class Plugin : ICommandAction
|
|||||||
|
|
||||||
switch ( args[0] )
|
switch ( args[0] )
|
||||||
{
|
{
|
||||||
|
case "refresh":
|
||||||
|
await Program.internalActionManager.Refresh();
|
||||||
|
break;
|
||||||
case "list":
|
case "list":
|
||||||
|
|
||||||
var data = await manager.GetAvailablePlugins();
|
var data = await manager.GetAvailablePlugins();
|
||||||
@@ -163,7 +167,12 @@ public class Plugin : ICommandAction
|
|||||||
|
|
||||||
if (pluginRequirements == string.Empty)
|
if (pluginRequirements == string.Empty)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Plugin installed successfully");
|
Console.WriteLine("Finished installing " + pluginName + " successfully");
|
||||||
|
Console.WriteLine("Reloading plugins list...");
|
||||||
|
await Program.internalActionManager.Execute("plugin", "load");
|
||||||
|
await Program.internalActionManager.Refresh();
|
||||||
|
|
||||||
|
Console.WriteLine("Finished reloading plugins list");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,16 +188,22 @@ public class Plugin : ICommandAction
|
|||||||
var filename = reqdata[1];
|
var filename = reqdata[1];
|
||||||
|
|
||||||
Console.WriteLine($"Downloading {filename}... ");
|
Console.WriteLine($"Downloading {filename}... ");
|
||||||
|
progress = new Progress<float>(p => { spinner.Message = $"Downloading {filename}... {Math.Round(p, 2)}% "; });
|
||||||
spinner.Start();
|
spinner.Start();
|
||||||
|
await ServerCom.DownloadFileAsync(url, $"./{filename}", progress);
|
||||||
await ServerCom.DownloadFileAsync(url, $"./{filename}.dll", null);
|
|
||||||
spinner.Stop();
|
spinner.Stop();
|
||||||
|
progress.Report(1);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
Console.WriteLine("Downloaded " + filename + " successfully");
|
Console.WriteLine("Downloaded " + filename + " successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Finished installing " + pluginName + " successfully");
|
Console.WriteLine("Finished installing " + pluginName + " successfully");
|
||||||
|
|
||||||
|
Console.WriteLine("Reloading plugins list...");
|
||||||
|
await Program.internalActionManager.Execute("plugin", "load");
|
||||||
|
await Program.internalActionManager.Refresh();
|
||||||
|
|
||||||
|
Console.WriteLine("Finished reloading plugins list");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public class PluginsManager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PluginsManager()
|
public PluginsManager()
|
||||||
{
|
{
|
||||||
PluginsLink = "https://raw.githubusercontent.com/andreitdr/installer/discord-bot-files/Plugins.txt";
|
PluginsLink = "https://raw.githubusercontent.com/andreitdr/SethPlugins/releases/PluginsList";
|
||||||
VersionsLink = "https://raw.githubusercontent.com/andreitdr/installer/discord-bot-files/Versions";
|
VersionsLink = "https://raw.githubusercontent.com/andreitdr/SethPlugins/releases/Versions";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user