Cleanup, tried to make parse optional
This commit is contained in:
parent
3b66f8106a
commit
4fce93c5cf
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,6 +25,7 @@ obj/
|
||||
!**/Bin/Debug/WebSocket4Net.dll
|
||||
!**/Bin/Debug/data/*
|
||||
!**/Bin/Debug/data/
|
||||
Tests/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
|
@ -72,17 +72,23 @@ namespace NadekoBot
|
||||
|
||||
private async Task StartCollecting() {
|
||||
while (true) {
|
||||
await Task.Delay(new TimeSpan(1, 0, 0));
|
||||
try {
|
||||
var obj = new ParseObject("Stats");
|
||||
obj["OnlineUsers"] = NadekoBot.client.Servers.Sum(x => x.Users.Count());
|
||||
obj["OnlineUsers"] = await Task.Run(() => NadekoBot.client.Servers.Sum(x => x.Users.Count()));
|
||||
obj["ConnectedServers"] = NadekoBot.client.Servers.Count();
|
||||
|
||||
obj.SaveAsync();
|
||||
await Task.Delay(new TimeSpan(1, 0, 0));
|
||||
await obj.SaveAsync();
|
||||
} catch (Exception) {
|
||||
Console.WriteLine("Parse exception in StartCollecting");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo - batch save this
|
||||
private void StatsCollector_RanCommand(object sender, CommandEventArgs e)
|
||||
{
|
||||
try {
|
||||
_commandsRan++;
|
||||
var obj = new ParseObject("CommandsRan");
|
||||
|
||||
@ -97,6 +103,9 @@ namespace NadekoBot
|
||||
|
||||
obj["CommandName"] = e.Command.Text;
|
||||
obj.SaveAsync();
|
||||
} catch (Exception) {
|
||||
Console.WriteLine("Parse error in ran command.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Shit parser. I used this to convert shit-format to json format
|
||||
/// </summary>
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,10 @@ namespace NadekoBot.Modules {
|
||||
class Administration : DiscordModule {
|
||||
public Administration() : base() {
|
||||
commands.Add(new HelpCommand());
|
||||
if(NadekoBot.ParseActive)
|
||||
commands.Add(new ServerGreetCommand());
|
||||
else
|
||||
Console.WriteLine("Parse not active. Server greet disabled.");
|
||||
}
|
||||
|
||||
public override void Install(ModuleManager manager) {
|
||||
|
@ -20,7 +20,10 @@ namespace NadekoBot.Modules {
|
||||
private string firestr = "🔥 ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้ 🔥";
|
||||
public Conversations() : base() {
|
||||
commands.Add(new CopyCommand());
|
||||
if(NadekoBot.ParseActive)
|
||||
commands.Add(new RequestsCommand());
|
||||
else
|
||||
Console.WriteLine("Requests don't work, parse not valid.");
|
||||
}
|
||||
|
||||
public override void Install(ModuleManager manager) {
|
||||
|
@ -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")));
|
||||
|
||||
|
@ -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
|
||||
|
@ -138,7 +138,6 @@
|
||||
<Compile Include="Classes\Music\StreamRequest.cs" />
|
||||
<Compile Include="Classes\Music\SoundCloud.cs" />
|
||||
<Compile Include="Commands\TriviaCommand.cs" />
|
||||
<Compile Include="Classes\SParser.cs" />
|
||||
<Compile Include="Classes\Trivia\TriviaGame.cs" />
|
||||
<Compile Include="Classes\Trivia\TriviaQuestion.cs" />
|
||||
<Compile Include="Classes\Trivia\TriviaQuestionPool.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user