Fixes. Improved .savechat

This commit is contained in:
Kwoth 2016-12-26 08:28:48 +01:00
parent 3bad28aa18
commit 94f1657a03
2 changed files with 33 additions and 24 deletions

View File

@ -650,8 +650,10 @@ namespace NadekoBot.Modules.Administration
cnt -= 100; cnt -= 100;
} }
var title = $"Chatlog-{channel.Guild.Name}/#{channel.Name}-{DateTime.Now}.txt"; var title = $"Chatlog-{channel.Guild.Name}/#{channel.Name}-{DateTime.Now}.txt";
var grouping = msgs.GroupBy(x => $"{x.CreatedAt.Date:dd.MM.yyyy}")
.Select(g => new { date = g.Key, messages = g.Select(s => $"【{s.Timestamp:HH:mm:ss}】{s.Author}:" + s.ToString()) });
await (umsg.Author as IGuildUser).SendFileAsync( await (umsg.Author as IGuildUser).SendFileAsync(
await JsonConvert.SerializeObject(new { Messages = msgs.Select(s => $"【{s.Timestamp:HH:mm:ss}】{s.Author}:" + s.ToString()) }, Formatting.Indented).ToStream().ConfigureAwait(false), await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false),
title, title).ConfigureAwait(false); title, title).ConfigureAwait(false);
} }

View File

@ -834,6 +834,8 @@ namespace NadekoBot.Modules.Searches
website = $"https://yande.re/post.xml?limit=100&tags={tag}"; website = $"https://yande.re/post.xml?limit=100&tags={tag}";
break; break;
} }
try
{
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
http.AddFakeHeaders(); http.AddFakeHeaders();
@ -849,6 +851,11 @@ namespace NadekoBot.Modules.Searches
return url; return url;
} }
} }
catch
{
return null;
}
}
public static async Task<bool> ValidateQuery(ITextChannel ch, string query) public static async Task<bool> ValidateQuery(ITextChannel ch, string query)
{ {
if (!string.IsNullOrEmpty(query.Trim())) return true; if (!string.IsNullOrEmpty(query.Trim())) return true;