.savechat moved to utility module
This commit is contained in:
parent
11da7c89b6
commit
f7e9463a94
@ -486,24 +486,6 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await Context.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false);
|
await Context.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
[OwnerOnly]
|
|
||||||
public async Task SaveChat(int cnt)
|
|
||||||
{
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
var msgs = new List<IMessage>(cnt);
|
|
||||||
await Context.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled)).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var title = $"Chatlog-{Context.Guild.Name}/#{Context.Channel.Name}-{DateTime.Now}.txt";
|
|
||||||
var grouping = msgs.GroupBy(x => $"{x.CreatedAt.Date:dd.MM.yyyy}")
|
|
||||||
.Select(g => new { date = g.Key, messages = g.OrderBy(x => x.CreatedAt).Select(s => $"【{s.Timestamp:HH:mm:ss}】{s.Author}:" + s.ToString()) });
|
|
||||||
await (Context.User as IGuildUser).SendFileAsync(
|
|
||||||
await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false),
|
|
||||||
title, title).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequireUserPermission(GuildPermission.MentionEveryone)]
|
[RequireUserPermission(GuildPermission.MentionEveryone)]
|
||||||
|
@ -13,6 +13,8 @@ using System.Net.Http;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using ImageSharp;
|
using ImageSharp;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Utility
|
namespace NadekoBot.Modules.Utility
|
||||||
{
|
{
|
||||||
@ -326,5 +328,22 @@ namespace NadekoBot.Modules.Utility
|
|||||||
.WithIsInline(false))))
|
.WithIsInline(false))))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[OwnerOnly]
|
||||||
|
public async Task SaveChat(int cnt)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
var msgs = new List<IMessage>(cnt);
|
||||||
|
await Context.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled)).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var title = $"Chatlog-{Context.Guild.Name}/#{Context.Channel.Name}-{DateTime.Now}.txt";
|
||||||
|
var grouping = msgs.GroupBy(x => $"{x.CreatedAt.Date:dd.MM.yyyy}")
|
||||||
|
.Select(g => new { date = g.Key, messages = g.OrderBy(x => x.CreatedAt).Select(s => $"【{s.Timestamp:HH:mm:ss}】{s.Author}:" + s.ToString()) });
|
||||||
|
await Context.User.SendFileAsync(
|
||||||
|
await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false), title, title).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user