stats collecting works now, optional

- ParseKey and parse ID are now optional. If you don't enter them,
logging will be disabled
- GoogleAPI key is optional but you won't be able to queue music.
- removed testq
This commit is contained in:
Kwoth 2016-01-11 20:35:49 +01:00
parent 6c9518020f
commit 066fc00bc7
3 changed files with 16 additions and 29 deletions

View File

@ -83,22 +83,6 @@ namespace NadekoBot.Modules {
} }
}); });
cgb.CreateCommand("testq")
.Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`")
.Parameter("Query", ParameterType.Unparsed)
.Do(async e => {
var youtube = YouTube.Default;
var video = youtube.GetAllVideos(e.GetArg("Query"))
.Where(v => v.AdaptiveKind == AdaptiveKind.Audio)
.OrderByDescending(v => v.AudioBitrate).FirstOrDefault();
if (video?.Uri != "" && video.Uri != null) {
SongQueue.Add(video);
await e.Send("**Queued** " + video.FullName+ video.Stream().Length);
}
});
cgb.CreateCommand("q") cgb.CreateCommand("q")
.Alias("yq") .Alias("yq")
.Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`") .Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`")

View File

@ -14,9 +14,9 @@ namespace NadekoBot
class NadekoBot class NadekoBot
{ {
public static DiscordClient client; public static DiscordClient client;
// public static StatsCollector stats_collector; public static StatsCollector stats_collector;
public static string botMention; public static string botMention;
public static string GoogleAPIKey; public static string GoogleAPIKey = null;
public static ulong OwnerID; public static ulong OwnerID;
public static string password; public static string password;
@ -28,7 +28,9 @@ namespace NadekoBot
{ {
c = JsonConvert.DeserializeObject<Credentials>(File.ReadAllText("credentials.json")); c = JsonConvert.DeserializeObject<Credentials>(File.ReadAllText("credentials.json"));
botMention = c.BotMention; botMention = c.BotMention;
GoogleAPIKey = c.GoogleAPIKey; if (c.GoogleAPIKey == null || c.GoogleAPIKey == "") {
Console.WriteLine("No google api key found. You will not be able to use music and links won't be shortened.");
}
OwnerID = c.OwnerID; OwnerID = c.OwnerID;
password = c.Password; password = c.Password;
} }
@ -39,14 +41,8 @@ namespace NadekoBot
return; return;
} }
client = new DiscordClient();
//init parse
if (c.ParseKey != null && c.ParseID != null)
ParseClient.Initialize(c.ParseID,c.ParseKey);
//create new discord client //create new discord client
client = new DiscordClient();
//create a command service //create a command service
var commandService = new CommandService(new CommandServiceConfig var commandService = new CommandService(new CommandServiceConfig
@ -55,8 +51,16 @@ namespace NadekoBot
HelpMode = HelpMode.Disable HelpMode = HelpMode.Disable
}); });
//monitor commands for logging //init parse
//stats_collector = new StatsCollector(commandService); if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") {
ParseClient.Initialize(c.ParseID, c.ParseKey);
//monitor commands for logging
stats_collector = new StatsCollector(commandService);
} else {
Console.WriteLine("Parse key and/or ID not found. Bot will not log.");
}
//add command service //add command service
var commands = client.Services.Add<CommandService>(commandService); var commands = client.Services.Add<CommandService>(commandService);

View File

@ -177,7 +177,6 @@ namespace NadekoBot
private void StatsCollector_RanCommand(object sender, CommandEventArgs e) private void StatsCollector_RanCommand(object sender, CommandEventArgs e)
{ {
Console.WriteLine("command ran");
commandsRan++; commandsRan++;
var obj = new ParseObject("CommandsRan"); var obj = new ParseObject("CommandsRan");