diff --git a/.gitignore b/.gitignore
index 3df07766..047e8378 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@ obj/
!**/Bin/Debug/WebSocket4Net.dll
!**/Bin/Debug/data/*
!**/Bin/Debug/data/
+Tests/
# NuGet Packages
*.nupkg
diff --git a/NadekoBot/Classes/NadekoStats.cs b/NadekoBot/Classes/NadekoStats.cs
index 61bed760..7bc90d8b 100644
--- a/NadekoBot/Classes/NadekoStats.cs
+++ b/NadekoBot/Classes/NadekoStats.cs
@@ -35,7 +35,7 @@ namespace NadekoBot
_statsSW = new Stopwatch();
_statsSW.Start();
_service.CommandExecuted += StatsCollector_RanCommand;
-
+
StartCollecting();
Console.WriteLine("Logging enabled.");
}
@@ -72,31 +72,40 @@ namespace NadekoBot
private async Task StartCollecting() {
while (true) {
- var obj = new ParseObject("Stats");
- obj["OnlineUsers"] = NadekoBot.client.Servers.Sum(x => x.Users.Count());
- obj["ConnectedServers"] = NadekoBot.client.Servers.Count();
-
- obj.SaveAsync();
await Task.Delay(new TimeSpan(1, 0, 0));
+ try {
+ var obj = new ParseObject("Stats");
+ obj["OnlineUsers"] = await Task.Run(() => NadekoBot.client.Servers.Sum(x => x.Users.Count()));
+ obj["ConnectedServers"] = NadekoBot.client.Servers.Count();
+
+ await obj.SaveAsync();
+ } catch (Exception) {
+ Console.WriteLine("Parse exception in StartCollecting");
+ break;
+ }
}
}
//todo - batch save this
private void StatsCollector_RanCommand(object sender, CommandEventArgs e)
{
- _commandsRan++;
- var obj = new ParseObject("CommandsRan");
+ try {
+ _commandsRan++;
+ var obj = new ParseObject("CommandsRan");
- obj["ServerId"] = e.Server.Id;
- obj["ServerName"] = e.Server.Name;
+ obj["ServerId"] = e.Server.Id;
+ obj["ServerName"] = e.Server.Name;
- obj["ChannelId"] = e.Channel.Id;
- obj["ChannelName"] = e.Channel.Name;
+ obj["ChannelId"] = e.Channel.Id;
+ obj["ChannelName"] = e.Channel.Name;
- obj["UserId"] = e.User.Id;
- obj["UserName"] = e.User.Name;
+ obj["UserId"] = e.User.Id;
+ obj["UserName"] = e.User.Name;
- obj["CommandName"] = e.Command.Text;
- obj.SaveAsync();
+ obj["CommandName"] = e.Command.Text;
+ obj.SaveAsync();
+ } catch (Exception) {
+ Console.WriteLine("Parse error in ran command.");
+ }
}
}
}
diff --git a/NadekoBot/Classes/SParser.cs b/NadekoBot/Classes/SParser.cs
deleted file mode 100644
index f0afe4af..00000000
--- a/NadekoBot/Classes/SParser.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace NadekoBot.Classes
-{
- ///
- /// Shit parser. I used this to convert shit-format to json format
- ///
- class SParser
- {
- public static void DoShitParse() {
-
- string[] lines = File.ReadAllLines("questions.txt");
- JArray qs = new JArray();
- foreach (var line in lines)
- {
- if (!line.Contains(";")) continue;
- JObject j = new JObject();
- if (line.Contains(":"))
- {
- j["Category"] = line.Substring(0, line.LastIndexOf(":"));
- j["Question"] = line.Substring(line.LastIndexOf(":") + 1, line.LastIndexOf(";") - line.LastIndexOf(":") - 1);
-
- }
- else {
- j["Question"] = line.Substring(0, line.LastIndexOf(";"));
- }
- j["Answer"] = line.Substring(line.LastIndexOf(";") + 1, line.Length - line.LastIndexOf(";") - 1).Trim();
- qs.Add(j);
- }
- File.WriteAllText("questions2.txt", qs.ToString());
- }
- }
-}
diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs
index 311bf82a..2c6cda55 100644
--- a/NadekoBot/Modules/Administration.cs
+++ b/NadekoBot/Modules/Administration.cs
@@ -14,7 +14,10 @@ namespace NadekoBot.Modules {
class Administration : DiscordModule {
public Administration() : base() {
commands.Add(new HelpCommand());
- commands.Add(new ServerGreetCommand());
+ if(NadekoBot.ParseActive)
+ commands.Add(new ServerGreetCommand());
+ else
+ Console.WriteLine("Parse not active. Server greet disabled.");
}
public override void Install(ModuleManager manager) {
diff --git a/NadekoBot/Modules/Conversations.cs b/NadekoBot/Modules/Conversations.cs
index 01572359..a3999350 100644
--- a/NadekoBot/Modules/Conversations.cs
+++ b/NadekoBot/Modules/Conversations.cs
@@ -20,7 +20,10 @@ namespace NadekoBot.Modules {
private string firestr = "🔥 ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้ 🔥";
public Conversations() : base() {
commands.Add(new CopyCommand());
- commands.Add(new RequestsCommand());
+ if(NadekoBot.ParseActive)
+ commands.Add(new RequestsCommand());
+ else
+ Console.WriteLine("Requests don't work, parse not valid.");
}
public override void Install(ModuleManager manager) {
diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs
index 674531eb..ee5c0b06 100644
--- a/NadekoBot/Modules/Music.cs
+++ b/NadekoBot/Modules/Music.cs
@@ -59,7 +59,7 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("q")
.Alias("yq")
- .Description("Queue a song using keywords or link. **You must be in a voice channel**.\n**Usage**: `!m q Dream Of Venice`")
+ .Description("Queue a song using keywords or link. Bot will join your voice channel. **You must be in a voice channel**.\n**Usage**: `!m q Dream Of Venice`")
.Parameter("query", ParameterType.Unparsed)
.Do(async e => await QueueSong(e,e.GetArg("query")));
diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs
index 50d5ea93..5847b847 100644
--- a/NadekoBot/NadekoBot.cs
+++ b/NadekoBot/NadekoBot.cs
@@ -21,6 +21,7 @@ namespace NadekoBot {
public static string TrelloAppKey;
public static bool ForwardMessages = false;
public static Credentials creds;
+ public static bool ParseActive = false;
static void Main() {
//load credentials from credentials.json
@@ -49,9 +50,9 @@ namespace NadekoBot {
}
if (string.IsNullOrWhiteSpace(creds.ParseID) || string.IsNullOrWhiteSpace(creds.ParseKey)) {
Console.WriteLine("Parse key and/or ID not found. Those are mandatory.");
- Console.ReadKey();
- return;
- }
+ ParseActive = false;
+ } else ParseActive = true;
+
if(string.IsNullOrWhiteSpace(creds.OsuApiKey))
Console.WriteLine("No osu API key found. Osu functionality is disabled.");
else
diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj
index 318fd31d..0fbbf8f2 100644
--- a/NadekoBot/NadekoBot.csproj
+++ b/NadekoBot/NadekoBot.csproj
@@ -138,7 +138,6 @@
-