This commit is contained in:
Alexey Golub
2020-01-11 17:28:01 +02:00
parent 5c2e725739
commit 26d713a17c
26 changed files with 268 additions and 282 deletions

View File

@@ -25,6 +25,12 @@ namespace DiscordChatExporter.Core.Services
string outputPath, ExportFormat format, int? partitionLimit,
DateTimeOffset? after = null, DateTimeOffset? before = null, IProgress<double>? progress = null)
{
// Get base file path from output path
var baseFilePath = GetFilePathFromOutputPath(outputPath, format, guild, channel, after, before);
// Create options
var options = new RenderOptions(baseFilePath, format, partitionLimit);
// Create context
var mentionableUsers = new HashSet<User>(IdBasedEqualityComparer.Instance);
var mentionableChannels = await _dataService.GetGuildChannelsAsync(token, guild.Id);
@@ -37,8 +43,7 @@ namespace DiscordChatExporter.Core.Services
);
// Create renderer
var baseFilePath = GetFilePathFromOutputPath(outputPath, format, context);
await using var renderer = new FacadeMessageRenderer(baseFilePath, format, context, partitionLimit);
await using var renderer = new MessageRenderer(options, context);
// Render messages
var renderedAnything = false;
@@ -61,12 +66,13 @@ namespace DiscordChatExporter.Core.Services
public partial class ExportService
{
private static string GetFilePathFromOutputPath(string outputPath, ExportFormat format, RenderContext context)
private static string GetFilePathFromOutputPath(string outputPath, ExportFormat format, Guild guild, Channel channel,
DateTimeOffset? after, DateTimeOffset? before)
{
// Output is a directory
if (Directory.Exists(outputPath) || string.IsNullOrWhiteSpace(Path.GetExtension(outputPath)))
{
var fileName = ExportLogic.GetDefaultExportFileName(format, context.Guild, context.Channel, context.After, context.Before);
var fileName = ExportLogic.GetDefaultExportFileName(format, guild, channel, after, before);
return Path.Combine(outputPath, fileName);
}