mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-16 03:42:30 +00:00
Formatting
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Tests.Infra;
|
namespace DiscordChatExporter.Cli.Tests.Infra;
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ public class HtmlForwardSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message
|
message.Text().Should().ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025");
|
||||||
.Text()
|
|
||||||
.Should()
|
|
||||||
.ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,4 +27,3 @@ public class JsonForwardSpecs
|
|||||||
forwardedMessage.GetProperty("timestamp").GetString().Should().StartWith("2025-12-29");
|
forwardedMessage.GetProperty("timestamp").GetString().Should().StartWith("2025-12-29");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public class PlainTextForwardSpecs
|
|||||||
var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.ForwardTestCases);
|
var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.ForwardTestCases);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
document
|
document.Should().ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025");
|
||||||
.Should()
|
|
||||||
.ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ public record MessageReference(
|
|||||||
MessageReferenceKind Kind,
|
MessageReferenceKind Kind,
|
||||||
Snowflake? MessageId,
|
Snowflake? MessageId,
|
||||||
Snowflake? ChannelId,
|
Snowflake? ChannelId,
|
||||||
Snowflake? GuildId)
|
Snowflake? GuildId
|
||||||
|
)
|
||||||
{
|
{
|
||||||
public static MessageReference Parse(JsonElement json)
|
public static MessageReference Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public record MessageSnapshot(
|
|||||||
string Content,
|
string Content,
|
||||||
IReadOnlyList<Attachment> Attachments,
|
IReadOnlyList<Attachment> Attachments,
|
||||||
IReadOnlyList<Embed> Embeds,
|
IReadOnlyList<Embed> Embeds,
|
||||||
IReadOnlyList<Sticker> Stickers)
|
IReadOnlyList<Sticker> Stickers
|
||||||
|
)
|
||||||
{
|
{
|
||||||
public static MessageSnapshot Parse(JsonElement json)
|
public static MessageSnapshot Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -23,37 +24,35 @@ public record MessageSnapshot(
|
|||||||
json.GetPropertyOrNull("timestamp")?.GetDateTimeOffsetOrNull()
|
json.GetPropertyOrNull("timestamp")?.GetDateTimeOffsetOrNull()
|
||||||
?? DateTimeOffset.MinValue;
|
?? DateTimeOffset.MinValue;
|
||||||
|
|
||||||
var editedTimestamp = json
|
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffsetOrNull();
|
||||||
.GetPropertyOrNull("edited_timestamp")
|
|
||||||
?.GetDateTimeOffsetOrNull();
|
|
||||||
|
|
||||||
var content = json.GetPropertyOrNull("content")?.GetStringOrNull() ?? "";
|
var content = json.GetPropertyOrNull("content")?.GetStringOrNull() ?? "";
|
||||||
|
|
||||||
var attachments =
|
var attachments =
|
||||||
json
|
json.GetPropertyOrNull("attachments")
|
||||||
.GetPropertyOrNull("attachments")
|
|
||||||
?.EnumerateArrayOrNull()
|
?.EnumerateArrayOrNull()
|
||||||
?.Select(Attachment.Parse)
|
?.Select(Attachment.Parse)
|
||||||
.ToArray()
|
.ToArray()
|
||||||
?? [];
|
?? [];
|
||||||
|
|
||||||
var embeds =
|
var embeds =
|
||||||
json
|
json.GetPropertyOrNull("embeds")?.EnumerateArrayOrNull()?.Select(Embed.Parse).ToArray()
|
||||||
.GetPropertyOrNull("embeds")
|
|
||||||
?.EnumerateArrayOrNull()
|
|
||||||
?.Select(Embed.Parse)
|
|
||||||
.ToArray()
|
|
||||||
?? [];
|
?? [];
|
||||||
|
|
||||||
var stickers =
|
var stickers =
|
||||||
json
|
json.GetPropertyOrNull("sticker_items")
|
||||||
.GetPropertyOrNull("sticker_items")
|
|
||||||
?.EnumerateArrayOrNull()
|
?.EnumerateArrayOrNull()
|
||||||
?.Select(Sticker.Parse)
|
?.Select(Sticker.Parse)
|
||||||
.ToArray()
|
.ToArray()
|
||||||
?? [];
|
?? [];
|
||||||
|
|
||||||
return new MessageSnapshot(timestamp,
|
return new MessageSnapshot(
|
||||||
editedTimestamp, content, attachments, embeds, stickers);
|
timestamp,
|
||||||
|
editedTimestamp,
|
||||||
|
content,
|
||||||
|
attachments,
|
||||||
|
embeds,
|
||||||
|
stickers
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
|
|||||||
|
|
||||||
_writer.WriteString(
|
_writer.WriteString(
|
||||||
"timestamp",
|
"timestamp",
|
||||||
Context.NormalizeDate(message.ForwardedMessage.Timestamp)
|
Context.NormalizeDate(message.ForwardedMessage.Timestamp)
|
||||||
);
|
);
|
||||||
|
|
||||||
_writer.WriteString(
|
_writer.WriteString(
|
||||||
|
|||||||
@@ -239,9 +239,9 @@ internal class PlainTextMessageWriter(Stream stream, ExportContext context)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _writer.WriteLineAsync(
|
await _writer.WriteLineAsync(
|
||||||
$"Originally sent: {Context.FormatDate(forwardedMessage.Timestamp)}"
|
$"Originally sent: {Context.FormatDate(forwardedMessage.Timestamp)}"
|
||||||
);
|
);
|
||||||
|
|
||||||
await WriteAttachmentsAsync(forwardedMessage.Attachments, cancellationToken);
|
await WriteAttachmentsAsync(forwardedMessage.Attachments, cancellationToken);
|
||||||
await WriteEmbedsAsync(forwardedMessage.Embeds, cancellationToken);
|
await WriteEmbedsAsync(forwardedMessage.Embeds, cancellationToken);
|
||||||
|
|||||||
Reference in New Issue
Block a user