mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 11:16:59 -04:00
Add call time for call status messages (#365)
This commit is contained in:
parent
82945ac3cf
commit
355b8cb8cf
3 changed files with 11 additions and 3 deletions
|
@ -32,10 +32,12 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
|||
public DateTimeOffset Timestamp { get; }
|
||||
|
||||
public DateTimeOffset? EditedTimestamp { get; }
|
||||
public DateTimeOffset? CallEndedTimestamp { get; }
|
||||
|
||||
public bool IsPinned { get; }
|
||||
|
||||
public string Content { get; }
|
||||
|
||||
|
||||
public IReadOnlyList<Attachment> Attachments { get; }
|
||||
|
||||
|
@ -51,6 +53,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
|||
User author,
|
||||
DateTimeOffset timestamp,
|
||||
DateTimeOffset? editedTimestamp,
|
||||
DateTimeOffset? callEndedTimestamp,
|
||||
bool isPinned,
|
||||
string content,
|
||||
IReadOnlyList<Attachment> attachments,
|
||||
|
@ -63,6 +66,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
|||
Author = author;
|
||||
Timestamp = timestamp;
|
||||
EditedTimestamp = editedTimestamp;
|
||||
CallEndedTimestamp = callEndedTimestamp;
|
||||
IsPinned = isPinned;
|
||||
Content = content;
|
||||
Attachments = attachments;
|
||||
|
@ -82,14 +86,16 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
|||
var author = json.GetProperty("author").Pipe(User.Parse);
|
||||
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
||||
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffset();
|
||||
var callEndedTimestamp = json.GetPropertyOrNull("call")?.GetPropertyOrNull("ended_timestamp")?.GetDateTimeOffset();
|
||||
var type = (MessageType) json.GetProperty("type").GetInt32();
|
||||
var isPinned = json.GetPropertyOrNull("pinned")?.GetBoolean() ?? false;
|
||||
|
||||
|
||||
var content = type switch
|
||||
{
|
||||
MessageType.RecipientAdd => "Added a recipient.",
|
||||
MessageType.RecipientRemove => "Removed a recipient.",
|
||||
MessageType.Call => "Started a call.",
|
||||
MessageType.Call => $"Started a call that lasted {callEndedTimestamp?.Pipe(t => t - timestamp).Pipe(t => (int) t.TotalMinutes) ?? 0} minutes.",
|
||||
MessageType.ChannelNameChange => "Changed the channel name.",
|
||||
MessageType.ChannelIconChange => "Changed the channel icon.",
|
||||
MessageType.ChannelPinnedMessage => "Pinned a message.",
|
||||
|
@ -119,13 +125,15 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
|||
author,
|
||||
timestamp,
|
||||
editedTimestamp,
|
||||
callEndedTimestamp,
|
||||
isPinned,
|
||||
content,
|
||||
attachments,
|
||||
embeds,
|
||||
reactions,
|
||||
mentionedUsers
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ namespace DiscordChatExporter.Domain.Exporting.Writers
|
|||
|
||||
await _writer.WriteAsync(CsvEncode(buffer.ToString()));
|
||||
}
|
||||
|
||||
public override async ValueTask WriteMessageAsync(Message message)
|
||||
{
|
||||
// Author ID
|
||||
|
|
|
@ -197,6 +197,7 @@ namespace DiscordChatExporter.Domain.Exporting.Writers
|
|||
_writer.WriteString("type", message.Type.ToString());
|
||||
_writer.WriteString("timestamp", message.Timestamp);
|
||||
_writer.WriteString("timestampEdited", message.EditedTimestamp);
|
||||
_writer.WriteString("callEndedTimestamp", message.CallEndedTimestamp);
|
||||
_writer.WriteBoolean("isPinned", message.IsPinned);
|
||||
|
||||
// Content
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue