From ca536db64670ff06a1f3d8ccb711ea019df11d1d Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 25 Jan 2016 02:06:38 +0100 Subject: [PATCH] fixed typestop, typeadd added, saving data in parse. --- NadekoBot/Commands/SpeedTyping.cs | 22 ++++++++++++++++++---- NadekoBot/StatsCollector.cs | 1 - 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/NadekoBot/Commands/SpeedTyping.cs b/NadekoBot/Commands/SpeedTyping.cs index 5cd8d7d7..c61350ce 100644 --- a/NadekoBot/Commands/SpeedTyping.cs +++ b/NadekoBot/Commands/SpeedTyping.cs @@ -10,11 +10,12 @@ using System.Threading; using System.Diagnostics; using Parse; -namespace NadekoBot { +namespace NadekoBot { public static class SentencesProvider { internal static string GetRandomSentence() { - return "Random ultra long test sentence that i have to type every time."; + var data = new ParseQuery("TypingArticles").FindAsync().Result; + return data.ToList()[(new Random()).Next(0, data.Count())].Get("text"); } } @@ -60,9 +61,9 @@ namespace NadekoBot { await Task.Delay(1000); i--; if (!IsActive) - break; + return; } - + await Stop(); await Start(); } @@ -124,6 +125,19 @@ namespace NadekoBot { cgb.CreateCommand("typestop") .Description("Stops a typing contest on the current channel.") .Do(QuitFunc()); + + cgb.CreateCommand("typeadd") + .Description("Adds a new article to the typing contest. Owner only.") + .Parameter("text",ParameterType.Unparsed) + .Do(async e => { + if (e.User.Id != NadekoBot.OwnerID || e.GetArg("text") == null) return; + + var obj = new ParseObject("TypingArticles"); + obj["text"] = e.GetArg("text"); + await obj.SaveAsync(); + await e.Send("Added new typing article."); + }); + //todo add user submissions } } } diff --git a/NadekoBot/StatsCollector.cs b/NadekoBot/StatsCollector.cs index ad682e08..466eb74a 100644 --- a/NadekoBot/StatsCollector.cs +++ b/NadekoBot/StatsCollector.cs @@ -84,7 +84,6 @@ namespace NadekoBot public static void DEBUG_LOG(string text) { #pragma warning disable CS4014 //NadekoBot.client.GetChannel(119365591852122112).Send(text); - //TODO YOU MIGHT WANT TO CHANGE THIS TO LOOK LIKE THE LINE ABOVE Console.WriteLine(text); #pragma warning restore CS4014 }