no idea, and improvements to logging

This commit is contained in:
Master Kwoth 2016-02-18 03:29:30 +01:00
parent e2d6d8aebf
commit 4404150693
2 changed files with 45 additions and 27 deletions

View File

@ -74,7 +74,7 @@ namespace NadekoBot.Classes.Music {
if (OnResolving != null) if (OnResolving != null)
OnResolving(); OnResolving();
var links = await SearchHelper.FindYoutubeUrlByKeywords(Query); var links = await SearchHelper.FindYoutubeUrlByKeywords(Query);
var allVideos = await YouTube.Default.GetAllVideosAsync(links); var allVideos = await Task.Factory.StartNew(async () => await YouTube.Default.GetAllVideosAsync(links)).Unwrap();
var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio); var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio);
var video = videos var video = videos
.Where(v => v.AudioBitrate < 192) .Where(v => v.AudioBitrate < 192)

View File

@ -27,10 +27,11 @@ namespace NadekoBot.Commands {
return; return;
} }
await e.Channel.SendMessage($"**NO LONGER LOGGIN IN {ch.Mention} CHANNEL**"); await e.Channel.SendMessage($"**NO LONGER LOGGING IN {ch.Mention} CHANNEL**");
}; };
private async void MsgRecivd(object sender, MessageEventArgs e) { private async void MsgRecivd(object sender, MessageEventArgs e) {
try {
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id) if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id)
return; return;
Channel ch; Channel ch;
@ -38,7 +39,10 @@ namespace NadekoBot.Commands {
return; return;
await ch.SendMessage($"`Type:` **Message received** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}"); await ch.SendMessage($"`Type:` **Message received** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}");
} }
catch { }
}
private async void MsgDltd(object sender, MessageEventArgs e) { private async void MsgDltd(object sender, MessageEventArgs e) {
try {
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id) if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id)
return; return;
Channel ch; Channel ch;
@ -46,7 +50,10 @@ namespace NadekoBot.Commands {
return; return;
await ch.SendMessage($"`Type:` **Message deleted** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}"); await ch.SendMessage($"`Type:` **Message deleted** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}");
} }
catch { }
}
private async void MsgUpdtd(object sender, MessageUpdatedEventArgs e) { private async void MsgUpdtd(object sender, MessageUpdatedEventArgs e) {
try {
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id) if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id)
return; return;
Channel ch; Channel ch;
@ -54,14 +61,25 @@ namespace NadekoBot.Commands {
return; return;
await ch.SendMessage($"`Type:` **Message updated** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n**BEFORE**: `{e.User}:` {e.Before.Text}\n---------------\n**AFTER**: `{e.User}:` {e.Before.Text}"); await ch.SendMessage($"`Type:` **Message updated** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n**BEFORE**: `{e.User}:` {e.Before.Text}\n---------------\n**AFTER**: `{e.User}:` {e.Before.Text}");
} }
catch { }
}
private async void UsrUpdtd(object sender, UserUpdatedEventArgs e) { private async void UsrUpdtd(object sender, UserUpdatedEventArgs e) {
try {
Channel ch;
if (!logs.TryGetValue(e.Server, out ch))
return;
string str = $"`Type:` **User updated** `Time:` **{DateTime.Now}**\n"; string str = $"`Type:` **User updated** `Time:` **{DateTime.Now}**\n";
if (e.Before.Name != e.After.Name) if (e.Before.Name != e.After.Name)
str += $"Name changed from `{e.Before.Name}` to `{e.After.Name}`"; str += $"**Name changed** `FROM` **{e.Before.Name}** `TO` **{e.After.Name}**";
else if (e.Before.AvatarUrl != e.After.AvatarUrl) else if (e.Before.AvatarUrl != e.After.AvatarUrl)
str += $"Avatar url changed from `{e.Before.AvatarUrl}` to `{e.After.AvatarUrl}`"; str += $"**Avatar url changed**\n `FROM`\n {e.Before.AvatarUrl}\n `TO` {e.After.AvatarUrl}";
else if (e.Before.Status != e.After.Status) else if (e.Before.Status != e.After.Status)
str += $"Status changed from `{e.Before.AvatarUrl}` to `{e.After.AvatarUrl}`"; str += $"**Status changed FROM** `{e.Before.Status}` **TO** `{e.After.Status}`";
else
return;
await ch.SendMessage(str);
}
catch { }
} }
public override void Init(CommandGroupBuilder cgb) { public override void Init(CommandGroupBuilder cgb) {
cgb.CreateCommand(".logserver") cgb.CreateCommand(".logserver")