|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using DiscordChatExporter.Cli.Internal;
|
|
|
|
|
using DiscordChatExporter.Cli.Verbs.Options;
|
|
|
|
|
using DiscordChatExporter.Core.Helpers;
|
|
|
|
|
using DiscordChatExporter.Core.Services;
|
|
|
|
@ -28,27 +29,29 @@ namespace DiscordChatExporter.Cli.Verbs
|
|
|
|
|
if (Options.MessageGroupLimit > 0)
|
|
|
|
|
settingsService.MessageGroupLimit = Options.MessageGroupLimit;
|
|
|
|
|
|
|
|
|
|
// Get chat log
|
|
|
|
|
var chatLog = await dataService.GetChatLogAsync(Options.GetToken(), Options.ChannelId,
|
|
|
|
|
Options.After, Options.Before);
|
|
|
|
|
|
|
|
|
|
// Generate file path if not set or is a directory
|
|
|
|
|
var filePath = Options.OutputPath;
|
|
|
|
|
if (filePath.IsBlank() || ExportHelper.IsDirectoryPath(filePath))
|
|
|
|
|
// Track progress
|
|
|
|
|
Console.Write($"Exporting channel [{Options.ChannelId}]... ");
|
|
|
|
|
using (var progress = new InlineProgress())
|
|
|
|
|
{
|
|
|
|
|
// Generate default file name
|
|
|
|
|
var fileName = ExportHelper.GetDefaultExportFileName(Options.ExportFormat, chatLog.Guild,
|
|
|
|
|
chatLog.Channel, Options.After, Options.Before);
|
|
|
|
|
|
|
|
|
|
// Combine paths
|
|
|
|
|
filePath = Path.Combine(filePath ?? "", fileName);
|
|
|
|
|
// Get chat log
|
|
|
|
|
var chatLog = await dataService.GetChatLogAsync(Options.GetToken(), Options.ChannelId,
|
|
|
|
|
Options.After, Options.Before, progress);
|
|
|
|
|
|
|
|
|
|
// Generate file path if not set or is a directory
|
|
|
|
|
var filePath = Options.OutputPath;
|
|
|
|
|
if (filePath.IsBlank() || ExportHelper.IsDirectoryPath(filePath))
|
|
|
|
|
{
|
|
|
|
|
// Generate default file name
|
|
|
|
|
var fileName = ExportHelper.GetDefaultExportFileName(Options.ExportFormat, chatLog.Guild,
|
|
|
|
|
chatLog.Channel, Options.After, Options.Before);
|
|
|
|
|
|
|
|
|
|
// Combine paths
|
|
|
|
|
filePath = Path.Combine(filePath ?? "", fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Export
|
|
|
|
|
exportService.ExportChatLog(chatLog, filePath, Options.ExportFormat, Options.PartitionLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Export
|
|
|
|
|
exportService.ExportChatLog(chatLog, filePath, Options.ExportFormat, Options.PartitionLimit);
|
|
|
|
|
|
|
|
|
|
// Print result
|
|
|
|
|
Console.WriteLine($"Exported chat to [{filePath}]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|