Added transcript dir to config

This commit is contained in:
Toastie 2024-12-27 19:36:02 +13:00
parent 0304744d9d
commit e3984ab968
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
4 changed files with 28 additions and 17 deletions

View file

@ -20,6 +20,7 @@ internal static class Config
internal static bool newCommandUsesSelector = false;
internal static int ticketLimit = 5;
internal static bool pinFirstMessage = false;
internal static string transcriptDir = "";
internal static bool ticketUpdatedNotifications = false;
internal static double ticketUpdatedNotificationDelay = 0.0;
@ -91,6 +92,7 @@ internal static class Config
newCommandUsesSelector = json.SelectToken("bot.new-command-uses-selector")?.Value<bool>() ?? false;
ticketLimit = json.SelectToken("bot.ticket-limit")?.Value<int>() ?? 5;
pinFirstMessage = json.SelectToken("bot.pin-first-message")?.Value<bool>() ?? false;
transcriptDir = json.SelectToken("bot.transcript-dir")?.Value<string>() ?? "";
ticketUpdatedNotifications = json.SelectToken("notifications.ticket-updated")?.Value<bool>() ?? false;
ticketUpdatedNotificationDelay = json.SelectToken("notifications.ticket-updated-delay")?.Value<double>() ?? 0.0;

View file

@ -27,7 +27,6 @@ internal static class SupportChild
"config",
Required = false,
HelpText = "Select a config file to use.",
Default = "config.yml",
MetaValue = "PATH")]
public string configPath { get; set; }
@ -35,7 +34,6 @@ internal static class SupportChild
"transcripts",
Required = false,
HelpText = "Select directory to store transcripts in.",
Default = "./transcripts",
MetaValue = "PATH")]
public string transcriptDir { get; set; }

View file

@ -13,23 +13,11 @@ namespace SupportChild;
internal static class Transcriber
{
private static string transcriptDir = "./transcripts"; // TODO: Should be local variable (or come from the config class) when added to config to avoid race conditions when reloading
internal static async Task ExecuteAsync(ulong channelID, uint ticketID)
{
DiscordClient discordClient = new DiscordClient(Config.token);
ChannelExporter exporter = new ChannelExporter(discordClient);
if (!string.IsNullOrEmpty(SupportChild.commandLineArgs.transcriptDir))
{
transcriptDir = SupportChild.commandLineArgs.transcriptDir;
}
if (!Directory.Exists(transcriptDir))
{
Directory.CreateDirectory(transcriptDir);
}
string htmlPath = GetHtmlPath(ticketID);
string zipPath = GetZipPath(ticketID);
string assetDirPath = GetAssetDirPath(ticketID);
@ -99,19 +87,39 @@ internal static class Transcriber
}
}
private static string GetTranscriptDir()
{
string transcriptDir = "./transcripts";
if (!string.IsNullOrEmpty(SupportChild.commandLineArgs.transcriptDir))
{
transcriptDir = SupportChild.commandLineArgs.transcriptDir;
}
else if (!string.IsNullOrEmpty(Config.transcriptDir))
{
transcriptDir = Config.transcriptDir;
}
if (!Directory.Exists(transcriptDir))
{
Directory.CreateDirectory(transcriptDir);
}
return transcriptDir;
}
internal static string GetHtmlPath(uint ticketNumber)
{
return transcriptDir + "/" + GetHTMLFilename(ticketNumber);
return GetTranscriptDir() + "/" + GetHTMLFilename(ticketNumber);
}
internal static string GetZipPath(uint ticketNumber)
{
return transcriptDir + "/" + GetZipFilename(ticketNumber);
return GetTranscriptDir() + "/" + GetZipFilename(ticketNumber);
}
internal static string GetAssetDirPath(uint ticketNumber)
{
return transcriptDir + "/" + GetAssetDirName(ticketNumber);
return GetTranscriptDir() + "/" + GetAssetDirName(ticketNumber);
}
internal static string GetAssetDirName(uint ticketNumber)

View file

@ -39,6 +39,9 @@
# Pins the first message in a ticket to allow for quick navigation to the top in large tickets.
pin-first-message: true
# Ticket transcript location, can be overridden using command line arguments.
transcript-dir: "./transcripts"
notifications:
# Notifies the assigned staff member when a new message is posted in a ticket if the ticket has been silent for a configurable amount of time.
# Other staff members and bots do not trigger this.