2022-04-18 10:52:03 +00:00
|
|
|
|
using System.IO;
|
2022-02-21 08:40:09 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using DiscordChatExporter.Core.Discord;
|
|
|
|
|
using DiscordChatExporter.Core.Discord.Data;
|
|
|
|
|
using DiscordChatExporter.Core.Exporting;
|
|
|
|
|
using DiscordChatExporter.Core.Exporting.Filtering;
|
|
|
|
|
using DiscordChatExporter.Core.Exporting.Partitioning;
|
|
|
|
|
|
2022-08-21 07:33:27 +00:00
|
|
|
|
namespace SupportChild;
|
|
|
|
|
|
|
|
|
|
internal static class Transcriber
|
2022-02-21 08:40:09 +00:00
|
|
|
|
{
|
2024-10-29 10:05:16 +00:00
|
|
|
|
private static string transcriptDir = "./transcripts";
|
|
|
|
|
|
2024-10-29 09:10:37 +00:00
|
|
|
|
internal static async Task ExecuteAsync(ulong channelID, uint ticketID)
|
|
|
|
|
{
|
|
|
|
|
DiscordClient discordClient = new DiscordClient(Config.token);
|
|
|
|
|
ChannelExporter exporter = new ChannelExporter(discordClient);
|
|
|
|
|
|
2024-10-29 10:05:16 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(SupportChild.commandLineArgs.transcriptDir))
|
|
|
|
|
{
|
|
|
|
|
transcriptDir = SupportChild.commandLineArgs.transcriptDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(transcriptDir))
|
2024-10-29 09:10:37 +00:00
|
|
|
|
{
|
2024-10-29 10:05:16 +00:00
|
|
|
|
Directory.CreateDirectory(transcriptDir);
|
2024-10-29 09:10:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Channel channel = await discordClient.GetChannelAsync(new Snowflake(channelID));
|
|
|
|
|
Guild guild = await discordClient.GetGuildAsync(channel.GuildId);
|
|
|
|
|
|
2024-10-29 09:52:02 +00:00
|
|
|
|
ExportRequest request = new(
|
|
|
|
|
guild,
|
|
|
|
|
channel,
|
|
|
|
|
GetPath(ticketID),
|
|
|
|
|
null,
|
|
|
|
|
ExportFormat.HtmlDark,
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
PartitionLimit.Null,
|
|
|
|
|
MessageFilter.Null,
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
"en-US",
|
|
|
|
|
true
|
|
|
|
|
);
|
2024-10-29 09:10:37 +00:00
|
|
|
|
|
|
|
|
|
await exporter.ExportChannelAsync(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static string GetPath(uint ticketNumber)
|
|
|
|
|
{
|
2024-10-29 10:05:16 +00:00
|
|
|
|
return transcriptDir + "/" + GetFilename(ticketNumber);
|
2024-10-29 09:10:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static string GetFilename(uint ticketNumber)
|
|
|
|
|
{
|
|
|
|
|
return "ticket-" + ticketNumber.ToString("00000") + ".html";
|
|
|
|
|
}
|
2022-05-17 13:11:57 +00:00
|
|
|
|
}
|