This commit is contained in:
2022-04-21 12:55:25 +03:00
parent c14044a77c
commit 22ef6f3427
14 changed files with 202 additions and 96 deletions

View File

@@ -14,28 +14,28 @@
"MusicCommands.dll": {}
}
},
"Discord.Net/3.1.0": {
"Discord.Net/3.5.0": {
"dependencies": {
"Discord.Net.Commands": "3.1.0",
"Discord.Net.Core": "3.1.0",
"Discord.Net.Interactions": "3.1.0",
"Discord.Net.Rest": "3.1.0",
"Discord.Net.WebSocket": "3.1.0",
"Discord.Net.Webhook": "3.1.0"
"Discord.Net.Commands": "3.5.0",
"Discord.Net.Core": "3.5.0",
"Discord.Net.Interactions": "3.5.0",
"Discord.Net.Rest": "3.5.0",
"Discord.Net.WebSocket": "3.5.0",
"Discord.Net.Webhook": "3.5.0"
}
},
"Discord.Net.Commands/3.1.0": {
"Discord.Net.Commands/3.5.0": {
"dependencies": {
"Discord.Net.Core": "3.1.0"
"Discord.Net.Core": "3.5.0"
},
"runtime": {
"lib/net5.0/Discord.Net.Commands.dll": {
"assemblyVersion": "3.1.0.0",
"fileVersion": "3.1.0.0"
"assemblyVersion": "3.5.0.0",
"fileVersion": "3.5.0.0"
}
}
},
"Discord.Net.Core/3.1.0": {
"Discord.Net.Core/3.5.0": {
"dependencies": {
"Newtonsoft.Json": "13.0.1",
"System.Collections.Immutable": "5.0.0",
@@ -44,59 +44,59 @@
},
"runtime": {
"lib/net5.0/Discord.Net.Core.dll": {
"assemblyVersion": "3.1.0.0",
"fileVersion": "3.1.0.0"
"assemblyVersion": "3.5.0.0",
"fileVersion": "3.5.0.0"
}
}
},
"Discord.Net.Interactions/3.1.0": {
"Discord.Net.Interactions/3.5.0": {
"dependencies": {
"Discord.Net.Core": "3.1.0",
"Discord.Net.Rest": "3.1.0",
"Discord.Net.WebSocket": "3.1.0",
"Discord.Net.Core": "3.5.0",
"Discord.Net.Rest": "3.5.0",
"Discord.Net.WebSocket": "3.5.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
"System.Collections.Immutable": "5.0.0",
"System.Reactive": "5.0.0"
},
"runtime": {
"lib/net5.0/Discord.Net.Interactions.dll": {
"assemblyVersion": "3.1.0.0",
"fileVersion": "3.1.0.0"
"assemblyVersion": "3.5.0.0",
"fileVersion": "3.5.0.0"
}
}
},
"Discord.Net.Rest/3.1.0": {
"Discord.Net.Rest/3.5.0": {
"dependencies": {
"Discord.Net.Core": "3.1.0"
"Discord.Net.Core": "3.5.0"
},
"runtime": {
"lib/net5.0/Discord.Net.Rest.dll": {
"assemblyVersion": "3.1.0.0",
"fileVersion": "3.1.0.0"
"assemblyVersion": "3.5.0.0",
"fileVersion": "3.5.0.0"
}
}
},
"Discord.Net.Webhook/3.1.0": {
"Discord.Net.Webhook/3.5.0": {
"dependencies": {
"Discord.Net.Core": "3.1.0",
"Discord.Net.Rest": "3.1.0"
"Discord.Net.Core": "3.5.0",
"Discord.Net.Rest": "3.5.0"
},
"runtime": {
"lib/net5.0/Discord.Net.Webhook.dll": {
"assemblyVersion": "3.1.0.0",
"fileVersion": "3.1.0.0"
"assemblyVersion": "3.5.0.0",
"fileVersion": "3.5.0.0"
}
}
},
"Discord.Net.WebSocket/3.1.0": {
"Discord.Net.WebSocket/3.5.0": {
"dependencies": {
"Discord.Net.Core": "3.1.0",
"Discord.Net.Rest": "3.1.0"
"Discord.Net.Core": "3.5.0",
"Discord.Net.Rest": "3.5.0"
},
"runtime": {
"lib/net5.0/Discord.Net.WebSocket.dll": {
"assemblyVersion": "3.1.0.0",
"fileVersion": "3.1.0.0"
"assemblyVersion": "3.5.0.0",
"fileVersion": "3.5.0.0"
}
}
},
@@ -147,7 +147,7 @@
"System.ValueTuple/4.5.0": {},
"PluginManager/1.0.0": {
"dependencies": {
"Discord.Net": "3.1.0"
"Discord.Net": "3.5.0"
},
"runtime": {
"PluginManager.dll": {}
@@ -161,54 +161,54 @@
"serviceable": false,
"sha512": ""
},
"Discord.Net/3.1.0": {
"Discord.Net/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-GAY7d+k8UN5BsObGpysvg7ca6YwTqvesTouM8S8eBWSmwGnK38iceVkURg0QNAG70tlJ4w8S/BOjocRRvXU2MQ==",
"path": "discord.net/3.1.0",
"hashPath": "discord.net.3.1.0.nupkg.sha512"
"sha512": "sha512-IUtexpvogudb1rllKBWkIEpBVQoToMjtVo81KPkt+gNMe7KtRDcZJgcn6+72viMtyw0e95OJPXFV5VEA/n2OQQ==",
"path": "discord.net/3.5.0",
"hashPath": "discord.net.3.5.0.nupkg.sha512"
},
"Discord.Net.Commands/3.1.0": {
"Discord.Net.Commands/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-EZdtrAqj6Uspyz4CvIwFP/UQ4XUpXjIPG1b5LrfAKOo12ks4k6XO7up2h+UsHexk7mEz4sfZxkEXGrW6PSh+/Q==",
"path": "discord.net.commands/3.1.0",
"hashPath": "discord.net.commands.3.1.0.nupkg.sha512"
"sha512": "sha512-ClTv8aiTlitvS48YatRiTLvgE2f2uKgmHNPVBIuvJBHZO2u4bZCzoN1fid+pZn2sbVOkt8uftlLGzz5DSZlFIA==",
"path": "discord.net.commands/3.5.0",
"hashPath": "discord.net.commands.3.5.0.nupkg.sha512"
},
"Discord.Net.Core/3.1.0": {
"Discord.Net.Core/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Oxz3CiWVvenSaHRYZeCKgRqzcWqdjGYmpxVVN2vPikt6bTN+xHAR4jczk8plKDDdINt7Lac37iLsRaqzUtJZpQ==",
"path": "discord.net.core/3.1.0",
"hashPath": "discord.net.core.3.1.0.nupkg.sha512"
"sha512": "sha512-rCzzaznMVQ+bLMxOpYwTyqm9V22kMy6BxlQisSxemHZDe2Jedz3Clp/a0dToACLz+Dlp3u+jYUfCBnTz7L6f4g==",
"path": "discord.net.core/3.5.0",
"hashPath": "discord.net.core.3.5.0.nupkg.sha512"
},
"Discord.Net.Interactions/3.1.0": {
"Discord.Net.Interactions/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-XzLChVRQGniUU8kdLMDYEOjifzvrcsOiAdKm/pO/PGPpZSMWSzPWlJUWaQlWMtOImrYULzRejOeoc2/3K3R30Q==",
"path": "discord.net.interactions/3.1.0",
"hashPath": "discord.net.interactions.3.1.0.nupkg.sha512"
"sha512": "sha512-wE9+V9DJ7r+1s4euOi4sGPIAt4sD7r+Tk5s9mrlbLCHVQTK4KllAvcrL25bPFI38FuFceREEzFoRlTrekSyB2Q==",
"path": "discord.net.interactions/3.5.0",
"hashPath": "discord.net.interactions.3.5.0.nupkg.sha512"
},
"Discord.Net.Rest/3.1.0": {
"Discord.Net.Rest/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-97kdAYjlNuuOnhRQW/OoGK2oBObvpzZlCSPJjIcI4DneEq6k2WIFhG00fvxK7DCVTlB5BgBMAT1BeRUk4/rUxQ==",
"path": "discord.net.rest/3.1.0",
"hashPath": "discord.net.rest.3.1.0.nupkg.sha512"
"sha512": "sha512-BnTdLFuuQsKvCv08VQrD4X1Hw2Xp+MELIRQiDiKfG01IiQlRTN+1gc3LB1zXgn5xBvC0HXjHxwV22GrMD9uKHQ==",
"path": "discord.net.rest/3.5.0",
"hashPath": "discord.net.rest.3.5.0.nupkg.sha512"
},
"Discord.Net.Webhook/3.1.0": {
"Discord.Net.Webhook/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-cZFxFf9H3GUBITlx1b7IskglgjJxSYpOIZOtyVW2WnPp7LpnxlOi1piRG22fH9fdhCC/RyDx3gZtYfN6WzacCw==",
"path": "discord.net.webhook/3.1.0",
"hashPath": "discord.net.webhook.3.1.0.nupkg.sha512"
"sha512": "sha512-vCIGZS+m88sQDuFmdbUqg+2RIXS/NJWx8ei3MX+ZEYiAvOkDgQfkIlEnU1NKpds6ivTt5GFlv6UzcWubb5VJ1w==",
"path": "discord.net.webhook/3.5.0",
"hashPath": "discord.net.webhook.3.5.0.nupkg.sha512"
},
"Discord.Net.WebSocket/3.1.0": {
"Discord.Net.WebSocket/3.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-6OsLNXHNKC/laDKoBD+T0Km0vzqHaCcBOaI/NA8Qsed935MtEOTy7juorF22gF6TYOeoclUgSINrHCY4zWvxpA==",
"path": "discord.net.websocket/3.1.0",
"hashPath": "discord.net.websocket.3.1.0.nupkg.sha512"
"sha512": "sha512-LjBOvcP40vJ+dhOtBDi8haEeblPAKpAIqR04NBzTM1/0RVavJZH89ovfSQIk42ygkiOaDV4E2x0Mmh6DRoIYcw==",
"path": "discord.net.websocket/3.5.0",
"hashPath": "discord.net.websocket.3.5.0.nupkg.sha512"
},
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
"type": "package",

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -25,7 +25,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.1.0" />
<PackageReference Include="Discord.Net" Version="3.5.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -137,7 +137,7 @@ namespace DiscordBot
{
string[] split = line.Split(',');
Console.WriteLine($"Downloading item: {split[1]}");
await ServerCom.DownloadFileAsync(split[0], split[1], i, lines.Count);
await ServerCom.DownloadFileAsync(split[0], "./" + split[1], i, lines.Count);
Functions.WriteColorText($"Downloaded item {split[1]}");
i++;
}

View File

@@ -1,26 +1,66 @@
using Discord.Net;
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace MusicCommands
{
public class LinkMusic
{
private string URL;
public string URL { get; private set; }
public LinkType type { get; private set; }
public LinkMusic(string URL)
{
this.URL = URL;
if (URL.StartsWith("https://www.youtube.com/watch?v="))
type = LinkType.YOUTUBE;
else if (URL.StartsWith("https://open.spotify.com/track/"))
type = LinkType.SPOTIFY;
else type = LinkType.RAW;
}
public async Task<Stream> GetMusicStreamAsync()
private async Task<string> GetYoutubeVideoID()
{
WebClient client = new WebClient();
return await client.OpenReadTaskAsync(this.URL);
//https://www.youtube.com/watch?v=i-p--m7qaCM&ab_channel=Leviathan
return URL.Split("=")[1].Split('&')[0];
}
public async Task<Stream> GetStream()
{
Stream s;
if (type == LinkType.SPOTIFY) s = await GetSpotifyMusicStreamAsync();
else if (type == LinkType.YOUTUBE) s = await GetYoutubeMusicStreamAsync();
else s = await GetRAWMusicStreamAsync();
return s;
}
private async Task<Stream> GetSpotifyMusicStreamAsync()
{
Stream response = null;
return response;
}
private async Task<Stream> GetYoutubeMusicStreamAsync()
{
//https://www.youtube.com/get_video_info?video_id={id}&el=detailpage
string ID = await GetYoutubeVideoID();
using (var webc = new WebClient())
{
Stream s = await webc.OpenReadTaskAsync($"https://www.youtube.com/get_video_info?video_id={ID}&el=detailpage");
string str = await new StreamReader(s).ReadToEndAsync();
Console.WriteLine(str);
await Task.Delay(-1);
}
return null;
}
private async Task<Stream> GetRAWMusicStreamAsync()
{
return await new WebClient().OpenReadTaskAsync(URL);
}
}
}

13
MusicCommands/LinkType.cs Normal file
View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MusicCommands
{
public enum LinkType
{
YOUTUBE, RAW, SPOTIFY
}
}

View File

@@ -2,10 +2,12 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Nullable>warnings</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>../BUILDS/</OutputPath>
<ErrorReport>none</ErrorReport>
</PropertyGroup>
<ItemGroup>

View File

@@ -7,13 +7,6 @@ using Discord;
using PluginManager.Interfaces;
using PluginManager.Others;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MusicCommands
{
class lplay : DBCommand
@@ -33,7 +26,6 @@ namespace MusicCommands
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
{
Data.voiceChannel = (context.User as IGuildUser)?.VoiceChannel;
if (Data.voiceChannel == null) { await context.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be passed as an argument."); return; }
@@ -44,7 +36,7 @@ namespace MusicCommands
if (Data.CurrentlyRunning != null)
Data.CurrentlyRunning.Stop();
LinkMusic music = new LinkMusic(Functions.GetArguments(message)[0]);
Data.CurrentlyRunning = new MusicPlayer(await music.GetMusicStreamAsync(), discord);
Data.CurrentlyRunning = new MusicPlayer(await music.GetStream(), discord);
await Data.CurrentlyRunning.StartSendAudio();
}
}

View File

@@ -32,15 +32,15 @@ namespace PluginManager.Online
var op = Functions.GetOperatinSystem();
string[] lines = text.Split('\n');
int len = lines.Length;
string[] titles = { "Name", "Description", "Plugin Type" };
data.Add(new string[] { "-", "-", "-" });
string[] titles = { "Name", "Description", "Plugin Type", "Libraries" };
data.Add(new string[] { "-", "-", "-", "-" });
data.Add(titles);
data.Add(new string[] { "-", "-", "-" });
data.Add(new string[] { "-", "-", "-", "-" });
for (int i = 0; i < len; i++)
{
if (lines[i].Length <= 2) continue;
string[] content = lines[i].Split(',');
string[] display = new string[3];
string[] display = new string[4];
if (op == PluginManager.Others.OperatingSystem.WINDOWS)
{
if (content[4].Contains("Windows"))
@@ -48,6 +48,10 @@ namespace PluginManager.Online
display[0] = content[0];
display[1] = content[1];
display[2] = content[2];
if (content.Length == 6 && (content[5] != null || content[5].Length > 2))
display[3] = ((await ServerCom.ReadTextFromFile(content[5])).Count + 1).ToString();
else display[3] = "1";
data.Add(display);
continue;
}
@@ -65,7 +69,7 @@ namespace PluginManager.Online
}
}
data.Add(new string[] { "-", "-", "-" });
data.Add(new string[] { "-", "-", "-", "-" });
Functions.FormatAndAlignTable(data);
}

View File

@@ -33,7 +33,7 @@ namespace PluginManager.Online
string oldTitle = Console.Title ?? "";
client.DownloadProgressChanged += (sender, e) =>
{
Console.Title = e.BytesReceived / 1024 + "/" + e.TotalBytesToReceive / 1024 + " (" + e.ProgressPercentage + "%) (" + downloadNumber + " / " + totalToDownload + ")";
Console.Title = e.BytesReceived + "/" + e.TotalBytesToReceive + " (" + e.ProgressPercentage + "%) (" + downloadNumber + " / " + totalToDownload + ")";
};
client.DownloadFileCompleted += (sender, e) =>
{

View File

@@ -174,14 +174,68 @@ namespace PluginManager.Others
return command.Arguments;
}
/// <summary>
/// A way to create a table based on input data
/// EpicWings (Pasca Robert) este cel mai bun
/// Special thanks to Kami-sama <3
/// </summary>
/// <param name="data">The List of arrays of strings that represent the rows.</param>
public static void FormatAndAlignTable(List<string[]> data)
{
char tableLine = '-';
char tableCross = '+';
char tableWall = '|';
int[] len = new int[data[0].Length];
foreach (var line in data)
{
for (int i = 0; i < line.Length; i++)
if (line[i].Length > len[i])
len[i] = line[i].Length;
}
foreach (string[] row in data)
{
//Console.Write("\t");
if (row[0][0] == tableLine) Console.Write(tableCross);
else Console.Write(tableWall);
for (int l = 0; l < row.Length; l++)
{
if (row[l][0] == tableLine)
{
for (int i = 0; i < len[l] + 4; ++i)
Console.Write(tableLine);
}
else if (row[l].Length == len[l])
{
Console.Write(" ");
Console.Write(row[l]);
Console.Write(" ");
}
else
{
int lenHalf = row[l].Length / 2;
for (int i = 0; i < ((len[l] + 4) / 2 - lenHalf); ++i)
Console.Write(" ");
Console.Write(row[l]);
for (int i = (len[l] + 4) / 2 + lenHalf + 1; i < len[l] + 4; ++i)
Console.Write(" ");
if (row[l].Length % 2 == 0)
Console.Write(" ");
}
if (row[l][0] == tableLine) Console.Write(tableCross);
else Console.Write(tableWall);
}
Console.WriteLine(); //end line
}
//Obsolite
#region Old Code -> Spacing by the lomgest item in any cell
/*
int maxLen = 0;
foreach (string[] row in data)
foreach (string s in row)
@@ -192,7 +246,7 @@ namespace PluginManager.Others
foreach (string[] row in data)
{
Console.Write("\t");
//Console.Write("\t");
if (row[0] == "-") Console.Write("+");
else Console.Write("|");
@@ -225,7 +279,8 @@ namespace PluginManager.Others
else Console.Write("|");
}
Console.WriteLine(); //end line
}
}*/
#endregion
}
/// <summary>

View File

@@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.1.0" />
<PackageReference Include="Discord.Net" Version="3.5.0" />
</ItemGroup>
</Project>