mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 19:26:57 -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 Timestamp { get; }
|
||||||
|
|
||||||
public DateTimeOffset? EditedTimestamp { get; }
|
public DateTimeOffset? EditedTimestamp { get; }
|
||||||
|
public DateTimeOffset? CallEndedTimestamp { get; }
|
||||||
|
|
||||||
public bool IsPinned { get; }
|
public bool IsPinned { get; }
|
||||||
|
|
||||||
public string Content { get; }
|
public string Content { get; }
|
||||||
|
|
||||||
|
|
||||||
public IReadOnlyList<Attachment> Attachments { get; }
|
public IReadOnlyList<Attachment> Attachments { get; }
|
||||||
|
|
||||||
|
@ -51,6 +53,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||||
User author,
|
User author,
|
||||||
DateTimeOffset timestamp,
|
DateTimeOffset timestamp,
|
||||||
DateTimeOffset? editedTimestamp,
|
DateTimeOffset? editedTimestamp,
|
||||||
|
DateTimeOffset? callEndedTimestamp,
|
||||||
bool isPinned,
|
bool isPinned,
|
||||||
string content,
|
string content,
|
||||||
IReadOnlyList<Attachment> attachments,
|
IReadOnlyList<Attachment> attachments,
|
||||||
|
@ -63,6 +66,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||||
Author = author;
|
Author = author;
|
||||||
Timestamp = timestamp;
|
Timestamp = timestamp;
|
||||||
EditedTimestamp = editedTimestamp;
|
EditedTimestamp = editedTimestamp;
|
||||||
|
CallEndedTimestamp = callEndedTimestamp;
|
||||||
IsPinned = isPinned;
|
IsPinned = isPinned;
|
||||||
Content = content;
|
Content = content;
|
||||||
Attachments = attachments;
|
Attachments = attachments;
|
||||||
|
@ -82,14 +86,16 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||||
var author = json.GetProperty("author").Pipe(User.Parse);
|
var author = json.GetProperty("author").Pipe(User.Parse);
|
||||||
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
||||||
var editedTimestamp = json.GetPropertyOrNull("edited_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 type = (MessageType) json.GetProperty("type").GetInt32();
|
||||||
var isPinned = json.GetPropertyOrNull("pinned")?.GetBoolean() ?? false;
|
var isPinned = json.GetPropertyOrNull("pinned")?.GetBoolean() ?? false;
|
||||||
|
|
||||||
|
|
||||||
var content = type switch
|
var content = type switch
|
||||||
{
|
{
|
||||||
MessageType.RecipientAdd => "Added a recipient.",
|
MessageType.RecipientAdd => "Added a recipient.",
|
||||||
MessageType.RecipientRemove => "Removed 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.ChannelNameChange => "Changed the channel name.",
|
||||||
MessageType.ChannelIconChange => "Changed the channel icon.",
|
MessageType.ChannelIconChange => "Changed the channel icon.",
|
||||||
MessageType.ChannelPinnedMessage => "Pinned a message.",
|
MessageType.ChannelPinnedMessage => "Pinned a message.",
|
||||||
|
@ -119,13 +125,15 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||||
author,
|
author,
|
||||||
timestamp,
|
timestamp,
|
||||||
editedTimestamp,
|
editedTimestamp,
|
||||||
|
callEndedTimestamp,
|
||||||
isPinned,
|
isPinned,
|
||||||
content,
|
content,
|
||||||
attachments,
|
attachments,
|
||||||
embeds,
|
embeds,
|
||||||
reactions,
|
reactions,
|
||||||
mentionedUsers
|
mentionedUsers
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ namespace DiscordChatExporter.Domain.Exporting.Writers
|
||||||
|
|
||||||
await _writer.WriteAsync(CsvEncode(buffer.ToString()));
|
await _writer.WriteAsync(CsvEncode(buffer.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async ValueTask WriteMessageAsync(Message message)
|
public override async ValueTask WriteMessageAsync(Message message)
|
||||||
{
|
{
|
||||||
// Author ID
|
// Author ID
|
||||||
|
|
|
@ -197,6 +197,7 @@ namespace DiscordChatExporter.Domain.Exporting.Writers
|
||||||
_writer.WriteString("type", message.Type.ToString());
|
_writer.WriteString("type", message.Type.ToString());
|
||||||
_writer.WriteString("timestamp", message.Timestamp);
|
_writer.WriteString("timestamp", message.Timestamp);
|
||||||
_writer.WriteString("timestampEdited", message.EditedTimestamp);
|
_writer.WriteString("timestampEdited", message.EditedTimestamp);
|
||||||
|
_writer.WriteString("callEndedTimestamp", message.CallEndedTimestamp);
|
||||||
_writer.WriteBoolean("isPinned", message.IsPinned);
|
_writer.WriteBoolean("isPinned", message.IsPinned);
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue