From bbb336f1a350423b68d122cbcba3e514aa468d3c Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Wed, 10 Feb 2016 13:44:19 +0100 Subject: [PATCH] reduced bandwidth usage, quality should be the same. Fixed reply bug --- NadekoBot/Classes/Music/StreamRequest.cs | 9 +++++---- NadekoBot/NadekoBot.cs | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/NadekoBot/Classes/Music/StreamRequest.cs b/NadekoBot/Classes/Music/StreamRequest.cs index 4dc13689..1ee7692a 100644 --- a/NadekoBot/Classes/Music/StreamRequest.cs +++ b/NadekoBot/Classes/Music/StreamRequest.cs @@ -79,11 +79,12 @@ namespace NadekoBot.Classes.Music { if (OnResolving != null) OnResolving(); var links = await Searches.FindYoutubeUrlByKeywords(Query); - var videos = await YouTube.Default.GetAllVideosAsync(links); + var allVideos = await YouTube.Default.GetAllVideosAsync(links); + var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio); var video = videos - .Where(v => v.AdaptiveKind == AdaptiveKind.Audio) - .OrderByDescending(v => v.AudioBitrate) - .FirstOrDefault(); + .Where(v => v.AudioBitrate < 256) + .OrderByDescending(v => v.AudioBitrate) + .FirstOrDefault(); if (video == null) // do something with this error throw new Exception("Could not load any video elements based on the query."); diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index c7635dcb..0803f8cb 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -143,13 +143,13 @@ namespace NadekoBot { if (ForwardMessages && OwnerUser != null) await OwnerUser.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```"); - if (repliedRecently = !repliedRecently) { + if (!repliedRecently) { await e.Send("**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\nYou can type `-h` or `-help` or `@MyName help` in any of the channels I am in and I will send you a message with my commands.\n Or you can find out what i do here: https://github.com/Kwoth/NadekoBot\nYou can also just send me an invite link to a server and I will join it.\nIf you don't want me on your server, you can simply ban me ;(\nBot Creator's server: https://discord.gg/0ehQwTK2RBhxEi0X"); Timer t = new Timer(); t.Interval = 2000; t.Start(); t.Elapsed += (s, ev) => { - repliedRecently = !repliedRecently; + repliedRecently = false; t.Stop(); t.Dispose(); };