Updated API for plugins to work with database from remote. Added PluginRepository and removed Installation Scripts

This commit is contained in:
2025-01-26 20:34:34 +02:00
parent 8b2169dc7b
commit 84b19e2069
35 changed files with 435 additions and 1056 deletions

View File

@@ -1,48 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using DiscordBotCore.Online.Helpers;
using DiscordBotCore.Others;
namespace DiscordBotCore.Online;
public static class ServerCom
{
/// <summary>
/// Read all lines from a file async
/// </summary>
/// <param name="link">The link of the file</param>
/// <returns></returns>
public static async Task<List<string>> ReadTextFromURL(string link)
{
var response = await OnlineFunctions.DownloadStringAsync(link);
var lines = response.Split('\n');
return lines.ToList();
}
/// <summary>
/// Get all text from a file async
/// </summary>
/// <param name="link">The link of the file</param>
/// <returns></returns>
public static async Task<string> GetAllTextFromUrl(string link)
{
var response = await OnlineFunctions.DownloadStringAsync(link);
return response;
}
/// <summary>
/// Download file from url
/// </summary>
/// <param name="URL">The url to the file</param>
/// <param name="location">The location where to store the downloaded data</param>
/// <param name="progress">The <see cref="IProgress{T}" /> to track the download</param>
/// <returns></returns>
public static async Task DownloadFileAsync(
private static async Task DownloadFileAsync(
string URL, string location, IProgress<float>? progress,
IProgress<long>? downloadedBytes)
{
@@ -60,34 +29,8 @@ public static class ServerCom
}
}
public static async Task DownloadFileAsync(string URl, string location, IProgress<float> progress)
public static async Task DownloadFileAsync(string url, string location, IProgress<float> progress)
{
await DownloadFileAsync(URl, location, progress, null);
await DownloadFileAsync(url, location, progress, null);
}
public static async Task DownloadFileAsync(string url, string location)
{
await DownloadFileAsync(url, location, null, null);
}
public static Task CreateDownloadTask(string URl, string location)
{
return DownloadFileAsync(URl, location, null, null);
}
public static Task CreateDownloadTask(string URl, string location, IProgress<float> progress)
{
return DownloadFileAsync(URl, location, progress, null);
}
public static async Task RunConsoleCommand(string console, string command)
{
Process process = new();
process.StartInfo.FileName = console;
process.StartInfo.Arguments = command;
process.Start();
await process.WaitForExitAsync();
}
}