mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-08-22 09:15:01 -05:00
Merge b23284514f into b11a57a825
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
# User-specific files
|
||||
.vs/
|
||||
.vscode/
|
||||
.idea/
|
||||
*.suo
|
||||
*.user
|
||||
|
||||
@@ -157,37 +157,51 @@ public partial class ExportRequest
|
||||
Channel channel,
|
||||
Snowflake? after,
|
||||
Snowflake? before
|
||||
) =>
|
||||
Regex.Replace(
|
||||
)
|
||||
{
|
||||
string preFormattedPath = Regex.Replace(
|
||||
path,
|
||||
"%.",
|
||||
m =>
|
||||
Path.EscapeFileName(
|
||||
m.Value switch
|
||||
{
|
||||
// On %T and %P, we have to make sure that we still get name and position of the category if the channel is a thread
|
||||
"%g" => guild.Id.ToString(),
|
||||
"%G" => guild.Name,
|
||||
|
||||
"%t" => channel.Parent?.Id.ToString() ?? "",
|
||||
"%T" => channel.Parent?.Name ?? "",
|
||||
"%T"
|
||||
=> channel.IsThread
|
||||
? (channel.Parent?.Parent?.Name ?? "")
|
||||
: channel.Parent?.Name ?? "",
|
||||
|
||||
"%c" => channel.Id.ToString(),
|
||||
"%C" => channel.Name,
|
||||
|
||||
"%p" => channel.Position?.ToString(CultureInfo.InvariantCulture) ?? "0",
|
||||
"%P" => channel.Parent?.Position?.ToString(CultureInfo.InvariantCulture)
|
||||
?? "0",
|
||||
"%P"
|
||||
=> channel.IsThread
|
||||
? (
|
||||
channel
|
||||
.Parent?.Parent
|
||||
?.Position
|
||||
?.ToString(CultureInfo.InvariantCulture) ?? ""
|
||||
)
|
||||
: channel.Parent?.Position?.ToString(CultureInfo.InvariantCulture)
|
||||
?? "0",
|
||||
|
||||
"%a" => after?.ToDate().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
|
||||
?? "",
|
||||
"%b" => before
|
||||
?.ToDate()
|
||||
.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
|
||||
?? "",
|
||||
"%d" => DateTimeOffset.Now.ToString(
|
||||
"yyyy-MM-dd",
|
||||
CultureInfo.InvariantCulture
|
||||
),
|
||||
"%a"
|
||||
=> after?.ToDate().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
|
||||
?? "",
|
||||
"%b"
|
||||
=> before?.ToDate().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
|
||||
?? "",
|
||||
"%d"
|
||||
=> DateTimeOffset.Now.ToString(
|
||||
"yyyy-MM-dd",
|
||||
CultureInfo.InvariantCulture
|
||||
),
|
||||
|
||||
"%%" => "%",
|
||||
_ => m.Value,
|
||||
@@ -195,6 +209,32 @@ public partial class ExportRequest
|
||||
)
|
||||
);
|
||||
|
||||
// We are looking for any structure in the path which contains either %y or %z. If the channel is a thread, we can resolve the placeholders, otherwise, that whole structure needs to be removed.
|
||||
string formattedPath = Regex.Replace(
|
||||
preFormattedPath,
|
||||
@"\\[^\\]*%[xyz][^\\]*\\",
|
||||
m =>
|
||||
channel.IsThread
|
||||
? Regex.Replace(
|
||||
m.Value,
|
||||
"%[xyz]",
|
||||
n =>
|
||||
n.Value switch
|
||||
{
|
||||
"%x" => channel.Parent?.Id.ToString() ?? "",
|
||||
"%y"
|
||||
=> channel
|
||||
.Parent?.Position
|
||||
?.ToString(CultureInfo.InvariantCulture) ?? "",
|
||||
"%z" => channel.Parent?.Name ?? "",
|
||||
_ => n.Value
|
||||
}
|
||||
)
|
||||
: "\\"
|
||||
);
|
||||
return formattedPath;
|
||||
}
|
||||
|
||||
private static string GetOutputBaseFilePath(
|
||||
Guild guild,
|
||||
Channel channel,
|
||||
|
||||
Reference in New Issue
Block a user