pull/66/head
Alexey Golub 6 years ago
parent 69088b83eb
commit 23f9331e4e

@ -6,19 +6,24 @@
{ {
public string Id { get; } public string Id { get; }
public bool IsImage { get; }
public string Url { get; } public string Url { get; }
public int? Width { get; }
public int? Height { get; }
public bool IsImage => Width != null;
public string FileName { get; } public string FileName { get; }
public long FileSize { get; } public long FileSize { get; }
public Attachment(string id, bool isImage, string url, string fileName, long fileSize) public Attachment(string id, int? width, int? height, string url, string fileName, long fileSize)
{ {
Id = id; Id = id;
IsImage = isImage;
Url = url; Url = url;
Width = width;
Height = height;
FileName = fileName; FileName = fileName;
FileSize = fileSize; FileSize = fileSize;
} }

@ -6,11 +6,11 @@ namespace DiscordChatExporter.Core.Models
{ {
public string Url { get; } public string Url { get; }
public int? Height { get; }
public int? Width { get; } public int? Width { get; }
public EmbedImage(string url, int? height, int? width) public int? Height { get; }
public EmbedImage(string url, int? width, int? height)
{ {
Url = url; Url = url;
Height = height; Height = height;

@ -35,10 +35,9 @@ img {
} }
.emoji { .emoji {
margin-left: 1px;
margin-right: 1px;
width: 24px; width: 24px;
height: 24px; height: 24px;
margin: 0 1px;
vertical-align: middle; vertical-align: middle;
} }
@ -61,9 +60,7 @@ img {
.info { .info {
display: flex; display: flex;
max-width: 100%; max-width: 100%;
margin-bottom: 10px; margin: 0 5px 10px 5px;
margin-left: 5px;
margin-right: 5px;
} }
.info__guild-icon-container { .info__guild-icon-container {
@ -108,10 +105,8 @@ img {
.chatlog__message-group { .chatlog__message-group {
display: flex; display: flex;
margin-left: 10px; margin: 0 10px;
margin-right: 10px; padding: 15px 0;
padding-top: 15px;
padding-bottom: 15px;
border-top: 1px solid; border-top: 1px solid;
} }
@ -154,8 +149,7 @@ img {
} }
.chatlog__attachment { .chatlog__attachment {
margin-top: 5px; margin: 5px 0;
margin-bottom: 5px;
} }
.chatlog__attachment-thumbnail { .chatlog__attachment-thumbnail {
@ -180,10 +174,7 @@ img {
.chatlog__embed-content-container { .chatlog__embed-content-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-left: 10px; padding: 8px 10px;
padding-top: 8px;
padding-right: 10px;
padding-bottom: 8px;
border: 1px solid; border: 1px solid;
border-top-right-radius: 3px; border-top-right-radius: 3px;
border-bottom-right-radius: 3px; border-bottom-right-radius: 3px;

@ -61,6 +61,18 @@ namespace DiscordChatExporter.Core.Services
return new Role(id, name); return new Role(id, name);
} }
private Attachment ParseAttachment(JToken json)
{
var id = json["id"].Value<string>();
var url = json["url"].Value<string>();
var width = json["width"]?.Value<int>();
var height = json["height"]?.Value<int>();
var fileName = json["filename"].Value<string>();
var fileSize = json["size"].Value<long>();
return new Attachment(id, width, height, url, fileName, fileSize);
}
private EmbedAuthor ParseEmbedAuthor(JToken json) private EmbedAuthor ParseEmbedAuthor(JToken json)
{ {
var name = json["name"]?.Value<string>(); var name = json["name"]?.Value<string>();
@ -79,24 +91,13 @@ namespace DiscordChatExporter.Core.Services
return new EmbedField(name, value, isInline); return new EmbedField(name, value, isInline);
} }
private Attachment ParseAttachment(JToken json)
{
var id = json["id"].Value<string>();
var url = json["url"].Value<string>();
var isImage = json["width"] != null;
var fileName = json["filename"].Value<string>();
var fileSize = json["size"].Value<long>();
return new Attachment(id, isImage, url, fileName, fileSize);
}
private EmbedImage ParseEmbedImage(JToken json) private EmbedImage ParseEmbedImage(JToken json)
{ {
var url = json["url"]?.Value<string>(); var url = json["url"]?.Value<string>();
var height = json["height"]?.Value<int>();
var width = json["width"]?.Value<int>(); var width = json["width"]?.Value<int>();
var height = json["height"]?.Value<int>();
return new EmbedImage(url, height, width); return new EmbedImage(url, width, height);
} }
private EmbedFooter ParseEmbedFooter(JToken json) private EmbedFooter ParseEmbedFooter(JToken json)
@ -188,7 +189,6 @@ namespace DiscordChatExporter.Core.Services
// Get mentioned users // Get mentioned users
var mentionedUsers = json["mentions"].EmptyIfNull().Select(ParseUser).ToArray(); var mentionedUsers = json["mentions"].EmptyIfNull().Select(ParseUser).ToArray();
return new Message(id, channelId, type, author, timestamp, editedTimestamp, content, attachments, embeds, return new Message(id, channelId, type, author, timestamp, editedTimestamp, content, attachments, embeds,
reactions, mentionedUsers); reactions, mentionedUsers);
} }

Loading…
Cancel
Save