woops, didn't push csproj
This commit is contained in:
parent
a0f14c9cd9
commit
1617994e20
@ -1,4 +1,4 @@
|
|||||||
using NadekoBot.Classes._DataModels;
|
using NadekoBot._DataModels;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -1,319 +0,0 @@
|
|||||||
/*
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
using Discord.Commands;
|
|
||||||
using Discord.Audio;
|
|
||||||
using System.IO;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using NadekoBot.Extensions;
|
|
||||||
using VideoLibrary;
|
|
||||||
|
|
||||||
namespace NadekoBot.Classes.Music {
|
|
||||||
|
|
||||||
public class StreamRequest {
|
|
||||||
public Server Server { get; }
|
|
||||||
public User User { get; }
|
|
||||||
public string Query { get; }
|
|
||||||
|
|
||||||
public string Title { get; internal set; } = String.Empty;
|
|
||||||
private string Provider { get; set; }
|
|
||||||
|
|
||||||
public string FullPrettyName => $"**【 {Title.TrimTo(55)} 】**`{(Provider == null ? "-" : Provider)}`";
|
|
||||||
|
|
||||||
private MusicStreamer musicStreamer = null;
|
|
||||||
public StreamState State => musicStreamer?.State ?? privateState;
|
|
||||||
private StreamState privateState = StreamState.Resolving;
|
|
||||||
|
|
||||||
public bool IsPaused => MusicControls.IsPaused;
|
|
||||||
|
|
||||||
public float Volume => MusicControls?.Volume ?? 1.0f;
|
|
||||||
|
|
||||||
public MusicType LinkType { get; }
|
|
||||||
|
|
||||||
public MusicPlayer MusicControls;
|
|
||||||
|
|
||||||
public StreamRequest(CommandEventArgs e, string query, MusicPlayer mc, MusicType musicType = MusicType.Normal) {
|
|
||||||
if (e == null)
|
|
||||||
throw new ArgumentNullException(nameof(e));
|
|
||||||
if (query == null)
|
|
||||||
throw new ArgumentNullException(nameof(query));
|
|
||||||
this.MusicControls = mc;
|
|
||||||
this.Server = e.Server;
|
|
||||||
this.Query = query;
|
|
||||||
this.LinkType = musicType;
|
|
||||||
mc.AddSong(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Resolve() {
|
|
||||||
string uri = null;
|
|
||||||
|
|
||||||
|
|
||||||
musicStreamer = new MusicStreamer(this, uri);
|
|
||||||
musicStreamer.OnCompleted += () => {
|
|
||||||
OnCompleted();
|
|
||||||
};
|
|
||||||
OnQueued();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string PrintStats() => musicStreamer?.Stats();
|
|
||||||
|
|
||||||
public event Action OnQueued = delegate { };
|
|
||||||
public event Action OnStarted = delegate { };
|
|
||||||
public event Action OnCompleted = delegate { };
|
|
||||||
public event Action<string> OnResolvingFailed = delegate { };
|
|
||||||
|
|
||||||
internal void Cancel() {
|
|
||||||
musicStreamer?.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Stop() {
|
|
||||||
musicStreamer?.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void Complete() {
|
|
||||||
OnCompleted();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task Start() {
|
|
||||||
int attemptsLeft = 4;
|
|
||||||
//wait for up to 4 seconds to resolve a link
|
|
||||||
try {
|
|
||||||
while (State == StreamState.Resolving) {
|
|
||||||
await Task.Delay(1000);
|
|
||||||
if (--attemptsLeft == 0) {
|
|
||||||
throw new TimeoutException("Resolving timed out.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OnStarted();
|
|
||||||
await musicStreamer.StartPlayback();
|
|
||||||
}
|
|
||||||
catch (TimeoutException) {
|
|
||||||
Console.WriteLine("Resolving timed out.");
|
|
||||||
privateState = StreamState.Completed;
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
Console.WriteLine("Error in start playback." + ex.Message);
|
|
||||||
privateState = StreamState.Completed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MusicStreamer {
|
|
||||||
private DualStream buffer;
|
|
||||||
|
|
||||||
public StreamState State { get; internal set; }
|
|
||||||
public string Url { get; }
|
|
||||||
private bool IsCanceled { get; set; }
|
|
||||||
public bool IsPaused => parent.IsPaused;
|
|
||||||
|
|
||||||
public event Action OnCompleted = delegate { };
|
|
||||||
|
|
||||||
StreamRequest parent;
|
|
||||||
private readonly object _bufferLock = new object();
|
|
||||||
private bool prebufferingComplete = false;
|
|
||||||
|
|
||||||
public MusicStreamer(StreamRequest parent, string directUrl) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.buffer = new DualStream();
|
|
||||||
this.Url = directUrl;
|
|
||||||
State = StreamState.Queued;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Stats() =>
|
|
||||||
"--------------------------------\n" +
|
|
||||||
$"Music stats for {string.Join("", parent.Title.TrimTo(50))}\n" +
|
|
||||||
$"Server: {parent.Server.Name}\n" +
|
|
||||||
$"Length:{buffer.Length * 1.0f / 1.MB()}MB Status: {State}\n" +
|
|
||||||
"--------------------------------\n";
|
|
||||||
|
|
||||||
private async Task BufferSong() {
|
|
||||||
//start feeding the buffer
|
|
||||||
|
|
||||||
Process p = null;
|
|
||||||
try {
|
|
||||||
var psi = new ProcessStartInfo {
|
|
||||||
FileName = "ffmpeg",
|
|
||||||
Arguments = $"-i {Url} -f s16le -ar 48000 -ac 2 pipe:1 -loglevel quiet", //+ (NadekoBot.IsLinux ? "2> /dev/null" : "2>NUL"),
|
|
||||||
UseShellExecute = false,
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
};
|
|
||||||
using (p = Process.Start(psi)) {
|
|
||||||
int attempt = 0;
|
|
||||||
while (true) {
|
|
||||||
while (buffer.writePos - buffer.readPos > 5.MB() && State != StreamState.Completed) {
|
|
||||||
prebufferingComplete = true;
|
|
||||||
await Task.Delay(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (State == StreamState.Completed) {
|
|
||||||
Console.WriteLine("Buffering canceled, stream is completed.");
|
|
||||||
try {
|
|
||||||
p.CancelOutputRead();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
try {
|
|
||||||
p.Close();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
p.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (buffer.readPos > 5.MiB() && buffer.writePos > 5.MiB()) {
|
|
||||||
var skip = 5.MB();
|
|
||||||
lock (_bufferLock) {
|
|
||||||
byte[] data = new byte[buffer.Length - skip];
|
|
||||||
Buffer.BlockCopy(buffer.GetBuffer(), skip, data, 0, (int)(buffer.Length - skip));
|
|
||||||
var newReadPos = buffer.readPos - skip;
|
|
||||||
var newPos = buffer.Position - skip;
|
|
||||||
buffer = new DualStream();
|
|
||||||
buffer.Write(data, 0, data.Length);
|
|
||||||
buffer.readPos = newReadPos;
|
|
||||||
buffer.Position = newPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int blockSize = 1920 * NadekoBot.client.GetService<AudioService>()?.Config?.Channels ?? 3840;
|
|
||||||
var buf = new byte[blockSize];
|
|
||||||
int read = 0;
|
|
||||||
read = await p.StandardOutput.BaseStream.ReadAsync(buf, 0, blockSize);
|
|
||||||
//Console.WriteLine($"Read: {read}");
|
|
||||||
if (read == 0) {
|
|
||||||
if (attempt == 5) {
|
|
||||||
Console.WriteLine($"Didn't read anything from the stream for {attempt} attempts. {buffer.Length / 1.MB()}MB length");
|
|
||||||
try {
|
|
||||||
p.CancelOutputRead();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
try {
|
|
||||||
p.Close();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
p.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
++attempt;
|
|
||||||
await Task.Delay(20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
attempt = 0;
|
|
||||||
lock (_bufferLock) {
|
|
||||||
buffer.Write(buf, 0, read);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
finally {
|
|
||||||
if (p != null) {
|
|
||||||
p.Dispose();
|
|
||||||
p = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task StartPlayback() {
|
|
||||||
Console.WriteLine("Starting playback.");
|
|
||||||
if (State == StreamState.Playing) return;
|
|
||||||
State = StreamState.Playing;
|
|
||||||
|
|
||||||
Task.Factory.StartNew(async () => {
|
|
||||||
await BufferSong();
|
|
||||||
}).ConfigureAwait(false);
|
|
||||||
|
|
||||||
// prebuffering wait stuff start
|
|
||||||
int bufferAttempts = 0;
|
|
||||||
int waitPerAttempt = 500;
|
|
||||||
int toAttemptTimes = parent.LinkType != MusicType.Normal ? 4 : 8;
|
|
||||||
while (!prebufferingComplete && bufferAttempts++ < toAttemptTimes) {
|
|
||||||
await Task.Delay(waitPerAttempt);
|
|
||||||
}
|
|
||||||
if (prebufferingComplete) {
|
|
||||||
Console.WriteLine($"Prebuffering finished in {bufferAttempts * 500}");
|
|
||||||
}
|
|
||||||
// prebuffering wait stuff end
|
|
||||||
|
|
||||||
if (buffer.Length > 0) {
|
|
||||||
Console.WriteLine("Prebuffering complete.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Console.WriteLine("Nothing was buffered, try another song and check your GoogleApikey.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int blockSize = 1920 * NadekoBot.client.GetService<AudioService>()?.Config?.Channels ?? 3840;
|
|
||||||
byte[] voiceBuffer = new byte[blockSize];
|
|
||||||
|
|
||||||
int attempt = 0;
|
|
||||||
while (!IsCanceled) {
|
|
||||||
int readCount = 0;
|
|
||||||
//adjust volume
|
|
||||||
|
|
||||||
lock (_bufferLock) {
|
|
||||||
readCount = buffer.Read(voiceBuffer, 0, blockSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readCount == 0) {
|
|
||||||
if (attempt == 4) {
|
|
||||||
Console.WriteLine($"Failed to read {attempt} times. Breaking out.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
++attempt;
|
|
||||||
await Task.Delay(15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
attempt = 0;
|
|
||||||
|
|
||||||
if (State == StreamState.Completed) {
|
|
||||||
Console.WriteLine("Canceled");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
voiceBuffer = adjustVolume(voiceBuffer, parent.Volume);
|
|
||||||
parent.MusicControls.VoiceClient.Send(voiceBuffer, 0, readCount);
|
|
||||||
|
|
||||||
while (IsPaused) {
|
|
||||||
await Task.Delay(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Cancel() {
|
|
||||||
IsCanceled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Stop() {
|
|
||||||
if (State == StreamState.Completed) return;
|
|
||||||
var oldState = State;
|
|
||||||
State = StreamState.Completed;
|
|
||||||
if (oldState == StreamState.Playing)
|
|
||||||
OnCompleted();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DualStream : MemoryStream {
|
|
||||||
public long readPos;
|
|
||||||
public long writePos;
|
|
||||||
|
|
||||||
public DualStream() {
|
|
||||||
readPos = writePos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Read(byte[] buffer, int offset, int count) {
|
|
||||||
Position = readPos;
|
|
||||||
int read = base.Read(buffer, offset, count);
|
|
||||||
readPos = Position;
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
public override void Write(byte[] buffer, int offset, int count) {
|
|
||||||
Position = writePos;
|
|
||||||
base.Write(buffer, offset, count);
|
|
||||||
writePos = Position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
@ -182,7 +182,7 @@ namespace NadekoBot
|
|||||||
.Sum(x => x.Users.Count(u => u.Status == UserStatus.Online)));
|
.Sum(x => x.Users.Count(u => u.Status == UserStatus.Online)));
|
||||||
var connectedServers = NadekoBot.Client.Servers.Count();
|
var connectedServers = NadekoBot.Client.Servers.Count();
|
||||||
|
|
||||||
Classes.DbHandler.Instance.InsertData(new Classes._DataModels.Stats
|
Classes.DbHandler.Instance.InsertData(new _DataModels.Stats
|
||||||
{
|
{
|
||||||
OnlineUsers = onlineUsers,
|
OnlineUsers = onlineUsers,
|
||||||
RealOnlineUsers = realOnlineUsers,
|
RealOnlineUsers = realOnlineUsers,
|
||||||
@ -207,7 +207,7 @@ namespace NadekoBot
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
commandsRan++;
|
commandsRan++;
|
||||||
Classes.DbHandler.Instance.InsertData(new Classes._DataModels.Command
|
Classes.DbHandler.Instance.InsertData(new _DataModels.Command
|
||||||
{
|
{
|
||||||
ServerId = (long)e.Server.Id,
|
ServerId = (long)e.Server.Id,
|
||||||
ServerName = e.Server.Name,
|
ServerName = e.Server.Name,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
|
using NadekoBot._DataModels;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes._DataModels;
|
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Administration.Commands;
|
using NadekoBot.Modules.Administration.Commands;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
@ -727,7 +727,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
SaveParseToDb<Announcement>("data/parsedata/Announcements.json");
|
SaveParseToDb<Announcement>("data/parsedata/Announcements.json");
|
||||||
SaveParseToDb<Classes._DataModels.Command>("data/parsedata/CommandsRan.json");
|
SaveParseToDb<_DataModels.Command>("data/parsedata/CommandsRan.json");
|
||||||
SaveParseToDb<Request>("data/parsedata/Requests.json");
|
SaveParseToDb<Request>("data/parsedata/Requests.json");
|
||||||
SaveParseToDb<Stats>("data/parsedata/Stats.json");
|
SaveParseToDb<Stats>("data/parsedata/Stats.json");
|
||||||
SaveParseToDb<TypingArticle>("data/parsedata/TypingArticles.json");
|
SaveParseToDb<TypingArticle>("data/parsedata/TypingArticles.json");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes._DataModels;
|
using NadekoBot._DataModels;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
NadekoBot.Client.UserJoined += UserJoined;
|
NadekoBot.Client.UserJoined += UserJoined;
|
||||||
NadekoBot.Client.UserLeft += UserLeft;
|
NadekoBot.Client.UserLeft += UserLeft;
|
||||||
|
|
||||||
var data = Classes.DbHandler.Instance.GetAllRows<Classes._DataModels.Announcement>();
|
var data = Classes.DbHandler.Instance.GetAllRows<_DataModels.Announcement>();
|
||||||
|
|
||||||
if (!data.Any()) return;
|
if (!data.Any()) return;
|
||||||
foreach (var obj in data)
|
foreach (var obj in data)
|
||||||
@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
public class AnnounceControls
|
public class AnnounceControls
|
||||||
{
|
{
|
||||||
private Classes._DataModels.Announcement _model { get; }
|
private _DataModels.Announcement _model { get; }
|
||||||
|
|
||||||
public bool Greet {
|
public bool Greet {
|
||||||
get { return _model.Greet; }
|
get { return _model.Greet; }
|
||||||
@ -160,14 +160,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
set { _model.ServerId = (long)value; }
|
set { _model.ServerId = (long)value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnnounceControls(Classes._DataModels.Announcement model)
|
public AnnounceControls(_DataModels.Announcement model)
|
||||||
{
|
{
|
||||||
this._model = model;
|
this._model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnnounceControls(ulong serverId)
|
public AnnounceControls(ulong serverId)
|
||||||
{
|
{
|
||||||
this._model = new Classes._DataModels.Announcement();
|
this._model = new _DataModels.Announcement();
|
||||||
ServerId = serverId;
|
ServerId = serverId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
{
|
{
|
||||||
public void SaveRequest(CommandEventArgs e, string text)
|
public void SaveRequest(CommandEventArgs e, string text)
|
||||||
{
|
{
|
||||||
Classes.DbHandler.Instance.InsertData(new Classes._DataModels.Request
|
DbHandler.Instance.InsertData(new _DataModels.Request
|
||||||
{
|
{
|
||||||
RequestText = text,
|
RequestText = text,
|
||||||
UserName = e.User.Name,
|
UserName = e.User.Name,
|
||||||
@ -23,7 +23,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
// todo what if it's too long?
|
// todo what if it's too long?
|
||||||
public string GetRequests()
|
public string GetRequests()
|
||||||
{
|
{
|
||||||
var task = Classes.DbHandler.Instance.GetAllRows<Classes._DataModels.Request>();
|
var task = DbHandler.Instance.GetAllRows<_DataModels.Request>();
|
||||||
|
|
||||||
var str = "Here are all current requests for NadekoBot:\n\n";
|
var str = "Here are all current requests for NadekoBot:\n\n";
|
||||||
foreach (var reqObj in task)
|
foreach (var reqObj in task)
|
||||||
@ -35,14 +35,14 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteRequest(int requestNumber) =>
|
public bool DeleteRequest(int requestNumber) =>
|
||||||
Classes.DbHandler.Instance.Delete<Classes._DataModels.Request>(requestNumber) != null;
|
DbHandler.Instance.Delete<_DataModels.Request>(requestNumber) != null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a request with a number and returns that request object.
|
/// Delete a request with a number and returns that request object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>RequestObject of the request. Null if none</returns>
|
/// <returns>RequestObject of the request. Null if none</returns>
|
||||||
public Classes._DataModels.Request ResolveRequest(int requestNumber) =>
|
public _DataModels.Request ResolveRequest(int requestNumber) =>
|
||||||
Classes.DbHandler.Instance.Delete<Classes._DataModels.Request>(requestNumber);
|
DbHandler.Instance.Delete<_DataModels.Request>(requestNumber);
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
if (string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
return;
|
return;
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
Classes.DbHandler.Instance.InsertData(new Classes._DataModels.UserQuote()
|
Classes.DbHandler.Instance.InsertData(new _DataModels.UserQuote()
|
||||||
{
|
{
|
||||||
DateAdded = DateTime.Now,
|
DateAdded = DateTime.Now,
|
||||||
Keyword = e.GetArg("keyword").ToLowerInvariant(),
|
Keyword = e.GetArg("keyword").ToLowerInvariant(),
|
||||||
@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var quote =
|
var quote =
|
||||||
Classes.DbHandler.Instance.GetRandom<Classes._DataModels.UserQuote>(
|
Classes.DbHandler.Instance.GetRandom<_DataModels.UserQuote>(
|
||||||
uqm => uqm.Keyword == keyword);
|
uqm => uqm.Keyword == keyword);
|
||||||
|
|
||||||
if (quote != null)
|
if (quote != null)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes._DataModels;
|
using NadekoBot._DataModels;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System;
|
using System;
|
||||||
|
@ -5,7 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace NadekoBot.Classes.Music
|
namespace NadekoBot.Modules.Music.Classes
|
||||||
{
|
{
|
||||||
|
|
||||||
public enum MusicType
|
public enum MusicType
|
@ -2,7 +2,7 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Classes.Music
|
namespace NadekoBot.Modules.Music.Classes
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
@ -1,4 +1,5 @@
|
|||||||
using Discord.Audio;
|
using Discord.Audio;
|
||||||
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -9,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using VideoLibrary;
|
using VideoLibrary;
|
||||||
|
|
||||||
namespace NadekoBot.Classes.Music
|
namespace NadekoBot.Modules.Music.Classes
|
||||||
{
|
{
|
||||||
public class SongInfo
|
public class SongInfo
|
||||||
{
|
{
|
@ -1,15 +1,19 @@
|
|||||||
using System;
|
using NadekoBot.Classes;
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Classes.Music {
|
namespace NadekoBot.Modules.Music.Classes
|
||||||
public class SoundCloud {
|
{
|
||||||
|
public class SoundCloud
|
||||||
|
{
|
||||||
private static readonly SoundCloud _instance = new SoundCloud();
|
private static readonly SoundCloud _instance = new SoundCloud();
|
||||||
public static SoundCloud Default => _instance;
|
public static SoundCloud Default => _instance;
|
||||||
|
|
||||||
static SoundCloud() { }
|
static SoundCloud() { }
|
||||||
public SoundCloud() { }
|
public SoundCloud() { }
|
||||||
|
|
||||||
public async Task<SoundCloudVideo> GetVideoAsync(string url) {
|
public async Task<SoundCloudVideo> GetVideoAsync(string url)
|
||||||
|
{
|
||||||
if (string.IsNullOrWhiteSpace(url))
|
if (string.IsNullOrWhiteSpace(url))
|
||||||
throw new ArgumentNullException(nameof(url));
|
throw new ArgumentNullException(nameof(url));
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.SoundCloudClientID))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.SoundCloudClientID))
|
||||||
@ -28,8 +32,9 @@ namespace NadekoBot.Classes.Music {
|
|||||||
System.Text.RegularExpressions.Regex.IsMatch(url, "(.*)(soundcloud.com|snd.sc)(.*)");
|
System.Text.RegularExpressions.Regex.IsMatch(url, "(.*)(soundcloud.com|snd.sc)(.*)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SoundCloudVideo {
|
public class SoundCloudVideo
|
||||||
public string Kind ="";
|
{
|
||||||
|
public string Kind = "";
|
||||||
public long Id = 0;
|
public long Id = 0;
|
||||||
public SoundCloudUser User = new SoundCloudUser();
|
public SoundCloudUser User = new SoundCloudUser();
|
||||||
public string Title = "";
|
public string Title = "";
|
||||||
@ -37,7 +42,8 @@ namespace NadekoBot.Classes.Music {
|
|||||||
public bool Streamable = false;
|
public bool Streamable = false;
|
||||||
public string StreamLink => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={NadekoBot.Creds.SoundCloudClientID}";
|
public string StreamLink => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={NadekoBot.Creds.SoundCloudClientID}";
|
||||||
}
|
}
|
||||||
public class SoundCloudUser {
|
public class SoundCloudUser
|
||||||
|
{
|
||||||
[Newtonsoft.Json.JsonProperty("username")]
|
[Newtonsoft.Json.JsonProperty("username")]
|
||||||
public string Name;
|
public string Name;
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
|
using NadekoBot._DataModels;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes._DataModels;
|
|
||||||
using NadekoBot.Classes.Music;
|
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
|
using NadekoBot.Modules.Music.Classes;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
@ -443,7 +443,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
var songInfos = currentPlaylist.Select(s => new Classes._DataModels.SongInfo
|
var songInfos = currentPlaylist.Select(s => new _DataModels.SongInfo
|
||||||
{
|
{
|
||||||
Provider = s.SongInfo.Provider,
|
Provider = s.SongInfo.Provider,
|
||||||
ProviderType = (int)s.SongInfo.ProviderType,
|
ProviderType = (int)s.SongInfo.ProviderType,
|
||||||
@ -519,7 +519,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
psi.PlaylistId == playlist.Id);
|
psi.PlaylistId == playlist.Id);
|
||||||
|
|
||||||
var songInfos = psis.Select(psi => DbHandler.Instance
|
var songInfos = psis.Select(psi => DbHandler.Instance
|
||||||
.FindOne<Classes._DataModels.SongInfo>(si => si.Id == psi.SongInfoId));
|
.FindOne<_DataModels.SongInfo>(si => si.Id == psi.SongInfoId));
|
||||||
|
|
||||||
await e.Channel.SendMessage($"`Attempting to load {songInfos.Count()} songs`");
|
await e.Channel.SendMessage($"`Attempting to load {songInfos.Count()} songs`");
|
||||||
foreach (var si in songInfos)
|
foreach (var si in songInfos)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes._DataModels;
|
using NadekoBot._DataModels;
|
||||||
using NadekoBot.Classes.JSONModels;
|
using NadekoBot.Classes.JSONModels;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
|
@ -134,32 +134,31 @@
|
|||||||
<Compile Include="Classes\JSONModels\PokemonType.cs" />
|
<Compile Include="Classes\JSONModels\PokemonType.cs" />
|
||||||
<Compile Include="Classes\JSONModels\_JSONModels.cs" />
|
<Compile Include="Classes\JSONModels\_JSONModels.cs" />
|
||||||
<Compile Include="Classes\Leet.cs" />
|
<Compile Include="Classes\Leet.cs" />
|
||||||
<Compile Include="Classes\Music\MusicControls.cs" />
|
<Compile Include="Modules\Music\Classes\MusicControls.cs" />
|
||||||
<Compile Include="Classes\Music\PoopyBuffer.cs" />
|
<Compile Include="Modules\Music\Classes\PoopyBuffer.cs" />
|
||||||
<Compile Include="Classes\Music\Song.cs" />
|
<Compile Include="Modules\Music\Classes\Song.cs" />
|
||||||
<Compile Include="Classes\Music\StreamRequest.cs" />
|
<Compile Include="Modules\Music\Classes\SoundCloud.cs" />
|
||||||
<Compile Include="Classes\Music\SoundCloud.cs" />
|
<Compile Include="Modules\Permissions\Classes\PermissionChecker.cs" />
|
||||||
<Compile Include="Classes\Permissions\PermissionChecker.cs" />
|
<Compile Include="Modules\Permissions\Classes\PermissionHelper.cs" />
|
||||||
<Compile Include="Classes\Permissions\PermissionHelper.cs" />
|
<Compile Include="Modules\Permissions\Classes\PermissionsHandler.cs" />
|
||||||
<Compile Include="Classes\Permissions\PermissionsHandler.cs" />
|
<Compile Include="Modules\Permissions\Classes\SimpleCheckers.cs" />
|
||||||
<Compile Include="Classes\Permissions\SimpleCheckers.cs" />
|
|
||||||
<Compile Include="Classes\SearchHelper.cs" />
|
<Compile Include="Classes\SearchHelper.cs" />
|
||||||
<Compile Include="Classes\ServerSpecificConfig.cs" />
|
<Compile Include="Classes\ServerSpecificConfig.cs" />
|
||||||
<Compile Include="Classes\_DataModels\AnnouncementModel.cs" />
|
<Compile Include="_DataModels\AnnouncementModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\CommandModel.cs" />
|
<Compile Include="_DataModels\CommandModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\CurrencyStateModel.cs" />
|
<Compile Include="_DataModels\CurrencyStateModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\CurrencyTransactionModel.cs" />
|
<Compile Include="_DataModels\CurrencyTransactionModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\Donator.cs" />
|
<Compile Include="_DataModels\Donator.cs" />
|
||||||
<Compile Include="Classes\_DataModels\IDataModel.cs" />
|
<Compile Include="_DataModels\IDataModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\MusicPlaylist.cs" />
|
<Compile Include="_DataModels\MusicPlaylist.cs" />
|
||||||
<Compile Include="Classes\_DataModels\PlaylistSongInfo.cs" />
|
<Compile Include="_DataModels\PlaylistSongInfo.cs" />
|
||||||
<Compile Include="Classes\_DataModels\PokeTypes.cs" />
|
<Compile Include="_DataModels\PokeTypes.cs" />
|
||||||
<Compile Include="Classes\_DataModels\Reminder.cs" />
|
<Compile Include="_DataModels\Reminder.cs" />
|
||||||
<Compile Include="Classes\_DataModels\RequestModel.cs" />
|
<Compile Include="_DataModels\RequestModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\SongInfo.cs" />
|
<Compile Include="_DataModels\SongInfo.cs" />
|
||||||
<Compile Include="Classes\_DataModels\StatsModel.cs" />
|
<Compile Include="_DataModels\StatsModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
|
<Compile Include="_DataModels\TypingArticleModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
|
<Compile Include="_DataModels\UserQuoteModel.cs" />
|
||||||
<Compile Include="Modules\Games\Commands\BetrayGame.cs" />
|
<Compile Include="Modules\Games\Commands\BetrayGame.cs" />
|
||||||
<Compile Include="Classes\DiscordCommand.cs" />
|
<Compile Include="Classes\DiscordCommand.cs" />
|
||||||
<Compile Include="Modules\Games\Commands\PlantPick.cs" />
|
<Compile Include="Modules\Games\Commands\PlantPick.cs" />
|
||||||
@ -176,9 +175,9 @@
|
|||||||
<Compile Include="Modules\Administration\Commands\PlayingRotate.cs" />
|
<Compile Include="Modules\Administration\Commands\PlayingRotate.cs" />
|
||||||
<Compile Include="Modules\Searches\Commands\StreamNotifications.cs" />
|
<Compile Include="Modules\Searches\Commands\StreamNotifications.cs" />
|
||||||
<Compile Include="Modules\Games\Commands\TriviaCommand.cs" />
|
<Compile Include="Modules\Games\Commands\TriviaCommand.cs" />
|
||||||
<Compile Include="Classes\Trivia\TriviaGame.cs" />
|
<Compile Include="Modules\Games\Commands\Trivia\TriviaGame.cs" />
|
||||||
<Compile Include="Classes\Trivia\TriviaQuestion.cs" />
|
<Compile Include="Modules\Games\Commands\Trivia\TriviaQuestion.cs" />
|
||||||
<Compile Include="Classes\Trivia\TriviaQuestionPool.cs" />
|
<Compile Include="Modules\Games\Commands\Trivia\TriviaQuestionPool.cs" />
|
||||||
<Compile Include="Modules\Conversations\Commands\RequestsCommand.cs" />
|
<Compile Include="Modules\Conversations\Commands\RequestsCommand.cs" />
|
||||||
<Compile Include="Modules\Administration\Commands\ServerGreetCommand.cs" />
|
<Compile Include="Modules\Administration\Commands\ServerGreetCommand.cs" />
|
||||||
<Compile Include="Modules\Games\Commands\SpeedTyping.cs" />
|
<Compile Include="Modules\Games\Commands\SpeedTyping.cs" />
|
||||||
@ -472,7 +471,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="Classes\Permissions\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class Announcement : IDataModel {
|
internal class Announcement : IDataModel {
|
||||||
public long ServerId { get; set; } = 0;
|
public long ServerId { get; set; } = 0;
|
||||||
public bool Greet { get; set; } = false;
|
public bool Greet { get; set; } = false;
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class Command : IDataModel {
|
internal class Command : IDataModel {
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class CurrencyState : IDataModel {
|
internal class CurrencyState : IDataModel {
|
||||||
public long Value { get; set; }
|
public long Value { get; set; }
|
||||||
[SQLite.Unique]
|
[SQLite.Unique]
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class CurrencyTransaction : IDataModel {
|
internal class CurrencyTransaction : IDataModel {
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
public int Value { get; set; }
|
public int Value { get; set; }
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class Donator : IDataModel {
|
internal class Donator : IDataModel {
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
@ -1,7 +1,7 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NadekoBot.Classes._DataModels
|
namespace NadekoBot._DataModels
|
||||||
{
|
{
|
||||||
internal abstract class IDataModel
|
internal abstract class IDataModel
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels
|
namespace NadekoBot._DataModels
|
||||||
{
|
{
|
||||||
internal class MusicPlaylist : IDataModel
|
internal class MusicPlaylist : IDataModel
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels
|
namespace NadekoBot._DataModels
|
||||||
{
|
{
|
||||||
internal class PlaylistSongInfo : IDataModel
|
internal class PlaylistSongInfo : IDataModel
|
||||||
{
|
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Classes._DataModels
|
namespace NadekoBot._DataModels
|
||||||
{
|
{
|
||||||
class UserPokeTypes : IDataModel
|
class UserPokeTypes : IDataModel
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NadekoBot.Classes._DataModels
|
namespace NadekoBot._DataModels
|
||||||
{
|
{
|
||||||
class Reminder : IDataModel
|
class Reminder : IDataModel
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class Request : IDataModel {
|
internal class Request : IDataModel {
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
@ -1,6 +1,6 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace NadekoBot.Classes._DataModels
|
namespace NadekoBot._DataModels
|
||||||
{
|
{
|
||||||
internal class SongInfo : IDataModel
|
internal class SongInfo : IDataModel
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class Stats : IDataModel {
|
internal class Stats : IDataModel {
|
||||||
public int ConnectedServers { get; set; }
|
public int ConnectedServers { get; set; }
|
||||||
public int OnlineUsers { get; set; }
|
public int OnlineUsers { get; set; }
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class TypingArticle : IDataModel {
|
internal class TypingArticle : IDataModel {
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Classes._DataModels {
|
namespace NadekoBot._DataModels {
|
||||||
internal class UserQuote : IDataModel {
|
internal class UserQuote : IDataModel {
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string Keyword { get; set; }
|
public string Keyword { get; set; }
|
Loading…
Reference in New Issue
Block a user