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,41 +27,59 @@ 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) {
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id) try {
return; if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id)
Channel ch; return;
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch) Channel ch;
return; if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
await ch.SendMessage($"`Type:` **Message received** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}"); return;
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) {
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id) try {
return; if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id)
Channel ch; return;
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch) Channel ch;
return; if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
await ch.SendMessage($"`Type:` **Message deleted** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}"); return;
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) {
if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id) try {
return; if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.client.CurrentUser.Id)
Channel ch; return;
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch) Channel ch;
return; if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
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}"); 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}");
}
catch { }
} }
private async void UsrUpdtd(object sender, UserUpdatedEventArgs e) { private async void UsrUpdtd(object sender, UserUpdatedEventArgs e) {
string str = $"`Type:` **User updated** `Time:` **{DateTime.Now}**\n"; try {
if (e.Before.Name != e.After.Name) Channel ch;
str += $"Name changed from `{e.Before.Name}` to `{e.After.Name}`"; if (!logs.TryGetValue(e.Server, out ch))
else if (e.Before.AvatarUrl != e.After.AvatarUrl) return;
str += $"Avatar url changed from `{e.Before.AvatarUrl}` to `{e.After.AvatarUrl}`"; string str = $"`Type:` **User updated** `Time:` **{DateTime.Now}**\n";
else if (e.Before.Status != e.After.Status) if (e.Before.Name != e.After.Name)
str += $"Status changed from `{e.Before.AvatarUrl}` to `{e.After.AvatarUrl}`"; str += $"**Name changed** `FROM` **{e.Before.Name}** `TO` **{e.After.Name}**";
else if (e.Before.AvatarUrl != 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)
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")