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/WebSocket4Net.dll
|
||||||
!**/Bin/Debug/data/*
|
!**/Bin/Debug/data/*
|
||||||
!**/Bin/Debug/data/
|
!**/Bin/Debug/data/
|
||||||
|
Tests/
|
||||||
|
|
||||||
# NuGet Packages
|
# NuGet Packages
|
||||||
*.nupkg
|
*.nupkg
|
||||||
|
@ -35,7 +35,7 @@ namespace NadekoBot
|
|||||||
_statsSW = new Stopwatch();
|
_statsSW = new Stopwatch();
|
||||||
_statsSW.Start();
|
_statsSW.Start();
|
||||||
_service.CommandExecuted += StatsCollector_RanCommand;
|
_service.CommandExecuted += StatsCollector_RanCommand;
|
||||||
|
|
||||||
StartCollecting();
|
StartCollecting();
|
||||||
Console.WriteLine("Logging enabled.");
|
Console.WriteLine("Logging enabled.");
|
||||||
}
|
}
|
||||||
@ -72,31 +72,40 @@ namespace NadekoBot
|
|||||||
|
|
||||||
private async Task StartCollecting() {
|
private async Task StartCollecting() {
|
||||||
while (true) {
|
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));
|
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
|
//todo - batch save this
|
||||||
private void StatsCollector_RanCommand(object sender, CommandEventArgs e)
|
private void StatsCollector_RanCommand(object sender, CommandEventArgs e)
|
||||||
{
|
{
|
||||||
_commandsRan++;
|
try {
|
||||||
var obj = new ParseObject("CommandsRan");
|
_commandsRan++;
|
||||||
|
var obj = new ParseObject("CommandsRan");
|
||||||
|
|
||||||
obj["ServerId"] = e.Server.Id;
|
obj["ServerId"] = e.Server.Id;
|
||||||
obj["ServerName"] = e.Server.Name;
|
obj["ServerName"] = e.Server.Name;
|
||||||
|
|
||||||
obj["ChannelId"] = e.Channel.Id;
|
obj["ChannelId"] = e.Channel.Id;
|
||||||
obj["ChannelName"] = e.Channel.Name;
|
obj["ChannelName"] = e.Channel.Name;
|
||||||
|
|
||||||
obj["UserId"] = e.User.Id;
|
obj["UserId"] = e.User.Id;
|
||||||
obj["UserName"] = e.User.Name;
|
obj["UserName"] = e.User.Name;
|
||||||
|
|
||||||
obj["CommandName"] = e.Command.Text;
|
obj["CommandName"] = e.Command.Text;
|
||||||
obj.SaveAsync();
|
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 {
|
class Administration : DiscordModule {
|
||||||
public Administration() : base() {
|
public Administration() : base() {
|
||||||
commands.Add(new HelpCommand());
|
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) {
|
public override void Install(ModuleManager manager) {
|
||||||
|
@ -20,7 +20,10 @@ namespace NadekoBot.Modules {
|
|||||||
private string firestr = "🔥 ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้ 🔥";
|
private string firestr = "🔥 ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้ 🔥";
|
||||||
public Conversations() : base() {
|
public Conversations() : base() {
|
||||||
commands.Add(new CopyCommand());
|
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) {
|
public override void Install(ModuleManager manager) {
|
||||||
|
@ -59,7 +59,7 @@ namespace NadekoBot.Modules {
|
|||||||
|
|
||||||
cgb.CreateCommand("q")
|
cgb.CreateCommand("q")
|
||||||
.Alias("yq")
|
.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)
|
.Parameter("query", ParameterType.Unparsed)
|
||||||
.Do(async e => await QueueSong(e,e.GetArg("query")));
|
.Do(async e => await QueueSong(e,e.GetArg("query")));
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ namespace NadekoBot {
|
|||||||
public static string TrelloAppKey;
|
public static string TrelloAppKey;
|
||||||
public static bool ForwardMessages = false;
|
public static bool ForwardMessages = false;
|
||||||
public static Credentials creds;
|
public static Credentials creds;
|
||||||
|
public static bool ParseActive = false;
|
||||||
|
|
||||||
static void Main() {
|
static void Main() {
|
||||||
//load credentials from credentials.json
|
//load credentials from credentials.json
|
||||||
@ -49,9 +50,9 @@ namespace NadekoBot {
|
|||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(creds.ParseID) || string.IsNullOrWhiteSpace(creds.ParseKey)) {
|
if (string.IsNullOrWhiteSpace(creds.ParseID) || string.IsNullOrWhiteSpace(creds.ParseKey)) {
|
||||||
Console.WriteLine("Parse key and/or ID not found. Those are mandatory.");
|
Console.WriteLine("Parse key and/or ID not found. Those are mandatory.");
|
||||||
Console.ReadKey();
|
ParseActive = false;
|
||||||
return;
|
} else ParseActive = true;
|
||||||
}
|
|
||||||
if(string.IsNullOrWhiteSpace(creds.OsuApiKey))
|
if(string.IsNullOrWhiteSpace(creds.OsuApiKey))
|
||||||
Console.WriteLine("No osu API key found. Osu functionality is disabled.");
|
Console.WriteLine("No osu API key found. Osu functionality is disabled.");
|
||||||
else
|
else
|
||||||
|
@ -138,7 +138,6 @@
|
|||||||
<Compile Include="Classes\Music\StreamRequest.cs" />
|
<Compile Include="Classes\Music\StreamRequest.cs" />
|
||||||
<Compile Include="Classes\Music\SoundCloud.cs" />
|
<Compile Include="Classes\Music\SoundCloud.cs" />
|
||||||
<Compile Include="Commands\TriviaCommand.cs" />
|
<Compile Include="Commands\TriviaCommand.cs" />
|
||||||
<Compile Include="Classes\SParser.cs" />
|
|
||||||
<Compile Include="Classes\Trivia\TriviaGame.cs" />
|
<Compile Include="Classes\Trivia\TriviaGame.cs" />
|
||||||
<Compile Include="Classes\Trivia\TriviaQuestion.cs" />
|
<Compile Include="Classes\Trivia\TriviaQuestion.cs" />
|
||||||
<Compile Include="Classes\Trivia\TriviaQuestionPool.cs" />
|
<Compile Include="Classes\Trivia\TriviaQuestionPool.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user