More cleanup, removed parse completely...
This commit is contained in:
parent
34989ae9f4
commit
f61606f8bc
@ -1,6 +1,5 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Parse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -35,8 +34,8 @@ namespace NadekoBot
|
||||
_statsSW = new Stopwatch();
|
||||
_statsSW.Start();
|
||||
_service.CommandExecuted += StatsCollector_RanCommand;
|
||||
|
||||
StartCollecting();
|
||||
|
||||
Task.Run(() => StartCollecting());
|
||||
Console.WriteLine("Logging enabled.");
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,8 @@
|
||||
public string BotMention;
|
||||
public string GoogleAPIKey;
|
||||
public ulong OwnerID;
|
||||
public string ParseID;
|
||||
public string ParseKey;
|
||||
public string TrelloAppKey;
|
||||
public bool? ForwardMessages;
|
||||
public string OsuApiKey;
|
||||
public string SoundCloudClientID;
|
||||
public string MashapeKey;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ namespace NadekoBot.Commands {
|
||||
var task = Classes.DBHandler.Instance.GetAllRows<Classes._DataModels.Request>();
|
||||
|
||||
string str = "Here are all current requests for NadekoBot:\n\n";
|
||||
int i = 1;
|
||||
foreach (var reqObj in task) {
|
||||
str += $"{reqObj.Id}. by **{reqObj.UserName}** from **{reqObj.ServerName}** at {reqObj.DateAdded.ToLocalTime()}\n" +
|
||||
$"**{reqObj.RequestText}**\n----------\n";
|
||||
|
@ -7,7 +7,6 @@ using Discord.Commands;
|
||||
using System.Collections.Concurrent;
|
||||
using NadekoBot.Extensions;
|
||||
using Discord;
|
||||
using Parse;
|
||||
using System.ComponentModel;
|
||||
|
||||
/* Voltana's legacy
|
||||
@ -129,7 +128,7 @@ namespace NadekoBot.Commands {
|
||||
get { return (ulong)_model.ServerId; }
|
||||
set { _model.ServerId = (long)value; }
|
||||
}
|
||||
|
||||
|
||||
public AnnounceControls(Classes._DataModels.Announcement model) {
|
||||
this._model = model;
|
||||
}
|
||||
@ -238,7 +237,7 @@ namespace NadekoBot.Commands {
|
||||
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||
|
||||
AnnouncementsDictionary[e.Server.Id].ToggleByePM();
|
||||
if(AnnouncementsDictionary[e.Server.Id].ByePM)
|
||||
if (AnnouncementsDictionary[e.Server.Id].ByePM)
|
||||
await e.Send("Bye messages will be sent in a PM from now on.\n :warning: Keep in mind this might fail if the user and the bot have no common servers after the user leaves.");
|
||||
else
|
||||
await e.Send("Bye messages will be sent in a bound channel from now on.");
|
||||
|
@ -1,22 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using Parse;
|
||||
|
||||
namespace NadekoBot.Commands {
|
||||
namespace NadekoBot.Commands {
|
||||
|
||||
public static class SentencesProvider {
|
||||
internal static string GetRandomSentence() {
|
||||
var data = new ParseQuery<ParseObject>("TypingArticles").FindAsync().Result;
|
||||
var data = Classes.DBHandler.Instance.GetAllRows<Classes._DataModels.TypingArticle>();
|
||||
try {
|
||||
return data.ToList()[(new Random()).Next(0, data.Count())].Get<string>("text");
|
||||
return data.ToList()[new Random().Next(0, data.Count())].Text;
|
||||
} catch (Exception) {
|
||||
return "Failed retrieving data from parse. Owner didn't add any articles to type using `typeadd`.";
|
||||
}
|
||||
@ -30,7 +27,7 @@ namespace NadekoBot.Commands {
|
||||
public bool IsActive;
|
||||
private Stopwatch sw;
|
||||
private List<ulong> finishedUserIds;
|
||||
|
||||
|
||||
public TypingGame(Channel channel) {
|
||||
this.channel = channel;
|
||||
IsActive = false;
|
||||
@ -65,10 +62,10 @@ namespace NadekoBot.Commands {
|
||||
await Task.Delay(1000);
|
||||
await msg.Edit("Starting new typing contest in **1**...");
|
||||
await Task.Delay(1000);
|
||||
await msg.Edit($":book:**{currentSentence.Replace(" "," \x200B")}**:book:");
|
||||
await msg.Edit($":book:**{currentSentence.Replace(" ", " \x200B")}**:book:");
|
||||
sw.Start();
|
||||
HandleAnswers();
|
||||
|
||||
|
||||
while (i > 0) {
|
||||
await Task.Delay(1000);
|
||||
i--;
|
||||
@ -113,7 +110,7 @@ namespace NadekoBot.Commands {
|
||||
runningContests = new Dictionary<ulong, TypingGame>();
|
||||
}
|
||||
|
||||
public override Func<CommandEventArgs, Task> DoFunc()=>
|
||||
public override Func<CommandEventArgs, Task> DoFunc() =>
|
||||
async e => {
|
||||
if (runningContests.ContainsKey(e.User.Server.Id) && runningContests[e.User.Server.Id].IsActive) {
|
||||
await e.Send($"Contest already running in { runningContests[e.User.Server.Id].Channell.Mention } channel.");
|
||||
@ -124,15 +121,14 @@ namespace NadekoBot.Commands {
|
||||
return;
|
||||
}
|
||||
var tg = new TypingGame(e.Channel);
|
||||
runningContests.Add(e.Server.Id,tg);
|
||||
runningContests.Add(e.Server.Id, tg);
|
||||
await tg.Start();
|
||||
};
|
||||
|
||||
private Func<CommandEventArgs,Task> QuitFunc() =>
|
||||
private Func<CommandEventArgs, Task> QuitFunc() =>
|
||||
async e => {
|
||||
if (runningContests.ContainsKey(e.User.Server.Id) &&
|
||||
await runningContests[e.User.Server.Id].Stop())
|
||||
{
|
||||
await runningContests[e.User.Server.Id].Stop()) {
|
||||
runningContests.Remove(e.User.Server.Id);
|
||||
return;
|
||||
}
|
||||
@ -150,14 +146,16 @@ namespace NadekoBot.Commands {
|
||||
|
||||
cgb.CreateCommand("typeadd")
|
||||
.Description("Adds a new article to the typing contest. Owner only.")
|
||||
.Parameter("text",ParameterType.Unparsed)
|
||||
.Do(e => {
|
||||
.Parameter("text", ParameterType.Unparsed)
|
||||
.Do(async e => {
|
||||
if (e.User.Id != NadekoBot.OwnerID || string.IsNullOrWhiteSpace(e.GetArg("text"))) return;
|
||||
|
||||
Classes.DBHandler.Instance.InsertData(new Classes._DataModels.TypingArticle {
|
||||
Text = e.GetArg("text"),
|
||||
DateAdded = DateTime.Now
|
||||
});
|
||||
|
||||
await e.Send("Added new article for typing.");
|
||||
});
|
||||
|
||||
//todo add user submissions
|
||||
|
@ -224,7 +224,7 @@ namespace NadekoBot.Modules {
|
||||
await e.Send($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`");
|
||||
} catch (Exception) { }
|
||||
};
|
||||
} catch (Exception ex) {
|
||||
} catch {
|
||||
await e.Channel.SendMessage(":anger: Failed retrieving osu signature :\\");
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Parse;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules;
|
||||
using Discord.Modules;
|
||||
@ -22,7 +21,6 @@ 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,26 +47,11 @@ namespace NadekoBot {
|
||||
ForwardMessages = true;
|
||||
Console.WriteLine("Forwarding messages.");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(creds.ParseID) || string.IsNullOrWhiteSpace(creds.ParseKey)) {
|
||||
Console.WriteLine("Parse key and/or ID not found. Some functionality will be missing.");
|
||||
ParseActive = false;
|
||||
} else ParseActive = true;
|
||||
|
||||
if(string.IsNullOrWhiteSpace(creds.OsuApiKey))
|
||||
Console.WriteLine("No osu API key found. Osu functionality is disabled.");
|
||||
else
|
||||
Console.WriteLine("Osu enabled.");
|
||||
if(string.IsNullOrWhiteSpace(creds.SoundCloudClientID))
|
||||
Console.WriteLine("No soundcloud Client ID found. Soundcloud streaming is disabled.");
|
||||
else
|
||||
Console.WriteLine("SoundCloud streaming enabled.");
|
||||
|
||||
//init parse
|
||||
if (ParseActive)
|
||||
try {
|
||||
ParseClient.Initialize(creds.ParseID, creds.ParseKey);
|
||||
} catch (Exception) { Console.WriteLine("Parse exception. Probably wrong parse credentials."); }
|
||||
|
||||
OwnerID = creds.OwnerID;
|
||||
password = creds.Password;
|
||||
} catch (Exception ex) {
|
||||
|
@ -104,14 +104,6 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Parse, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Parse.1.6.2\lib\net45\Parse.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Parse.NetFx45, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Parse.1.6.2\lib\net45\Parse.NetFx45.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.105.2.3\lib\net452\RestSharp.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
Loading…
Reference in New Issue
Block a user