Added transcript dir to config
This commit is contained in:
parent
0304744d9d
commit
e3984ab968
4 changed files with 28 additions and 17 deletions
|
@ -20,6 +20,7 @@ internal static class Config
|
||||||
internal static bool newCommandUsesSelector = false;
|
internal static bool newCommandUsesSelector = false;
|
||||||
internal static int ticketLimit = 5;
|
internal static int ticketLimit = 5;
|
||||||
internal static bool pinFirstMessage = false;
|
internal static bool pinFirstMessage = false;
|
||||||
|
internal static string transcriptDir = "";
|
||||||
|
|
||||||
internal static bool ticketUpdatedNotifications = false;
|
internal static bool ticketUpdatedNotifications = false;
|
||||||
internal static double ticketUpdatedNotificationDelay = 0.0;
|
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;
|
newCommandUsesSelector = json.SelectToken("bot.new-command-uses-selector")?.Value<bool>() ?? false;
|
||||||
ticketLimit = json.SelectToken("bot.ticket-limit")?.Value<int>() ?? 5;
|
ticketLimit = json.SelectToken("bot.ticket-limit")?.Value<int>() ?? 5;
|
||||||
pinFirstMessage = json.SelectToken("bot.pin-first-message")?.Value<bool>() ?? false;
|
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;
|
ticketUpdatedNotifications = json.SelectToken("notifications.ticket-updated")?.Value<bool>() ?? false;
|
||||||
ticketUpdatedNotificationDelay = json.SelectToken("notifications.ticket-updated-delay")?.Value<double>() ?? 0.0;
|
ticketUpdatedNotificationDelay = json.SelectToken("notifications.ticket-updated-delay")?.Value<double>() ?? 0.0;
|
||||||
|
|
|
@ -27,7 +27,6 @@ internal static class SupportChild
|
||||||
"config",
|
"config",
|
||||||
Required = false,
|
Required = false,
|
||||||
HelpText = "Select a config file to use.",
|
HelpText = "Select a config file to use.",
|
||||||
Default = "config.yml",
|
|
||||||
MetaValue = "PATH")]
|
MetaValue = "PATH")]
|
||||||
public string configPath { get; set; }
|
public string configPath { get; set; }
|
||||||
|
|
||||||
|
@ -35,7 +34,6 @@ internal static class SupportChild
|
||||||
"transcripts",
|
"transcripts",
|
||||||
Required = false,
|
Required = false,
|
||||||
HelpText = "Select directory to store transcripts in.",
|
HelpText = "Select directory to store transcripts in.",
|
||||||
Default = "./transcripts",
|
|
||||||
MetaValue = "PATH")]
|
MetaValue = "PATH")]
|
||||||
public string transcriptDir { get; set; }
|
public string transcriptDir { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -13,23 +13,11 @@ namespace SupportChild;
|
||||||
|
|
||||||
internal static class Transcriber
|
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)
|
internal static async Task ExecuteAsync(ulong channelID, uint ticketID)
|
||||||
{
|
{
|
||||||
DiscordClient discordClient = new DiscordClient(Config.token);
|
DiscordClient discordClient = new DiscordClient(Config.token);
|
||||||
ChannelExporter exporter = new ChannelExporter(discordClient);
|
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 htmlPath = GetHtmlPath(ticketID);
|
||||||
string zipPath = GetZipPath(ticketID);
|
string zipPath = GetZipPath(ticketID);
|
||||||
string assetDirPath = GetAssetDirPath(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)
|
internal static string GetHtmlPath(uint ticketNumber)
|
||||||
{
|
{
|
||||||
return transcriptDir + "/" + GetHTMLFilename(ticketNumber);
|
return GetTranscriptDir() + "/" + GetHTMLFilename(ticketNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetZipPath(uint ticketNumber)
|
internal static string GetZipPath(uint ticketNumber)
|
||||||
{
|
{
|
||||||
return transcriptDir + "/" + GetZipFilename(ticketNumber);
|
return GetTranscriptDir() + "/" + GetZipFilename(ticketNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetAssetDirPath(uint ticketNumber)
|
internal static string GetAssetDirPath(uint ticketNumber)
|
||||||
{
|
{
|
||||||
return transcriptDir + "/" + GetAssetDirName(ticketNumber);
|
return GetTranscriptDir() + "/" + GetAssetDirName(ticketNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetAssetDirName(uint ticketNumber)
|
internal static string GetAssetDirName(uint ticketNumber)
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
# Pins the first message in a ticket to allow for quick navigation to the top in large tickets.
|
# Pins the first message in a ticket to allow for quick navigation to the top in large tickets.
|
||||||
pin-first-message: true
|
pin-first-message: true
|
||||||
|
|
||||||
|
# Ticket transcript location, can be overridden using command line arguments.
|
||||||
|
transcript-dir: "./transcripts"
|
||||||
|
|
||||||
notifications:
|
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.
|
# 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.
|
# Other staff members and bots do not trigger this.
|
||||||
|
|
Loading…
Reference in a new issue