From d1dce345fb33e5844fe7d57ce2eac2833b2e2228 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 7 Mar 2016 14:16:31 +0100 Subject: [PATCH] password optional (will ask you on bot start if empty), debugging code --- NadekoBot/Classes/JSONModels/Configuration.cs | 1 + NadekoBot/Classes/Music/Song.cs | 9 ++++----- NadekoBot/Commands/LoLCommands.cs | 2 +- NadekoBot/Commands/LogCommand.cs | 9 +++++++++ NadekoBot/NadekoBot.cs | 6 ++++++ NadekoBot/bin/Debug/data/config_example.json | 1 + 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/NadekoBot/Classes/JSONModels/Configuration.cs b/NadekoBot/Classes/JSONModels/Configuration.cs index 1ab910f6..7c762cfd 100644 --- a/NadekoBot/Classes/JSONModels/Configuration.cs +++ b/NadekoBot/Classes/JSONModels/Configuration.cs @@ -6,6 +6,7 @@ namespace NadekoBot.Classes.JSONModels { public bool DontJoinServers { get; set; } = false; public bool ForwardMessages { get; set; } = true; public bool IsRotatingStatus { get; set; } = false; + public bool SendPrivateMessageOnMention { get; set; } = false; public List RotatingStatuses { get; set; } = new List(); public HashSet ServerBlacklist { get; set; } = new HashSet(); public HashSet ChannelBlacklist { get; set; } = new HashSet(); diff --git a/NadekoBot/Classes/Music/Song.cs b/NadekoBot/Classes/Music/Song.cs index 2366f0ed..ff0e3f69 100644 --- a/NadekoBot/Classes/Music/Song.cs +++ b/NadekoBot/Classes/Music/Song.cs @@ -200,21 +200,20 @@ namespace NadekoBot.Classes.Music { cancelToken.ThrowIfCancellationRequested(); Console.WriteLine($"Prebuffering done? in {waitPerAttempt * bufferAttempts}"); const int blockSize = 3840; - var buffer = new byte[blockSize]; var attempt = 0; while (!cancelToken.IsCancellationRequested) { //Console.WriteLine($"Read: {songBuffer.ReadPosition}\nWrite: {songBuffer.WritePosition}\nContentLength:{songBuffer.ContentLength}\n---------"); + byte[] buffer = new byte[blockSize]; var read = songBuffer.Read(buffer, blockSize); if (read == 0) if (attempt++ == 20) { Console.WriteLine("Waiting to empty out buffer."); voiceClient.Wait(); - await bufferTask; - Console.WriteLine("Song finished."); - return; + Console.WriteLine($"Song finished. [{songBuffer.ContentLength}]"); + break; } else - await Task.Delay(50, cancelToken); + await Task.Delay(100, cancelToken); else attempt = 0; diff --git a/NadekoBot/Commands/LoLCommands.cs b/NadekoBot/Commands/LoLCommands.cs index 24eed0c7..7b305de6 100644 --- a/NadekoBot/Commands/LoLCommands.cs +++ b/NadekoBot/Commands/LoLCommands.cs @@ -269,7 +269,7 @@ Assists: {general["assists"]} Ban: {general["banRate"]}% await e.Channel.SendMessage(sb.ToString()); } catch (Exception ex) { - await e.Channel.SendMessage($"Fail:\n{ex}"); + await e.Channel.SendMessage($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience."); } }); } diff --git a/NadekoBot/Commands/LogCommand.cs b/NadekoBot/Commands/LogCommand.cs index f5dcffcd..6779e145 100644 --- a/NadekoBot/Commands/LogCommand.cs +++ b/NadekoBot/Commands/LogCommand.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Concurrent; +using System.Linq; using System.Timers; using System.Threading.Tasks; using Discord.Commands; @@ -37,6 +38,14 @@ namespace NadekoBot.Commands { NadekoBot.Client.MessageDeleted += MsgDltd; NadekoBot.Client.MessageUpdated += MsgUpdtd; NadekoBot.Client.UserUpdated += UsrUpdtd; + + //if (NadekoBot.Config.SendPrivateMessageOnMention) + // NadekoBot.Client.MessageReceived += async (s, e) => { + // if (e.Channel.IsPrivate) + // return; + // if (e.Message.MentionedUsers.Any()) + + // }; } public Func DoFunc() => async e => { diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index 3e4f5a20..52959f2a 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -50,6 +50,12 @@ namespace NadekoBot { return; } + //if password is not entered, prompt for password + if (string.IsNullOrWhiteSpace(Creds.Password)) { + Console.WriteLine("Password blank. Please enter your password:\n"); + Creds.Password = Console.ReadLine(); + } + Console.WriteLine(string.IsNullOrWhiteSpace(Creds.GoogleAPIKey) ? "No google api key found. You will not be able to use music and links won't be shortened." : "Google API key provided."); diff --git a/NadekoBot/bin/Debug/data/config_example.json b/NadekoBot/bin/Debug/data/config_example.json index 185bca8d..200d3bf3 100644 --- a/NadekoBot/bin/Debug/data/config_example.json +++ b/NadekoBot/bin/Debug/data/config_example.json @@ -2,6 +2,7 @@ "DontJoinServers": false, "ForwardMessages": true, "IsRotatingStatus": false, + "SendPrivateMessageOnMention": false, "RotatingStatuses": [], "ServerBlacklist": [], "ChannelBlacklist": [],