From 3b5d752c95f136050d879fe15ec847808733779e Mon Sep 17 00:00:00 2001 From: Malcolm Diller Date: Thu, 9 May 2019 03:52:47 -0700 Subject: [PATCH] Add bot tags and some CSS fixes (#172) --- DiscordChatExporter.Core.Models/User.cs | 7 ++- .../Resources/HtmlShared.css | 46 ++++++++++++++++++- .../Resources/HtmlShared.html | 3 ++ .../DataService.Parsers.cs | 3 +- 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/DiscordChatExporter.Core.Models/User.cs b/DiscordChatExporter.Core.Models/User.cs index c239ef4..bd529c6 100644 --- a/DiscordChatExporter.Core.Models/User.cs +++ b/DiscordChatExporter.Core.Models/User.cs @@ -19,12 +19,15 @@ namespace DiscordChatExporter.Core.Models public string AvatarUrl { get; } - public User(string id, int discriminator, string name, string avatarHash) + public bool IsBot { get; } + + public User(string id, int discriminator, string name, string avatarHash, bool isBot) { Id = id; Discriminator = discriminator; Name = name; AvatarHash = avatarHash; + IsBot = isBot; FullName = GetFullName(name, discriminator); AvatarUrl = GetAvatarUrl(id, discriminator, avatarHash); @@ -54,6 +57,6 @@ namespace DiscordChatExporter.Core.Models return $"https://cdn.discordapp.com/embed/avatars/{discriminator % 5}.png"; } - public static User CreateUnknownUser(string id) => new User(id, 0, "Unknown", null); + public static User CreateUnknownUser(string id) => new User(id, 0, "Unknown", null, false); } } \ No newline at end of file diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css index 2027f03..19c74b0 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css @@ -1,5 +1,35 @@ /* === GENERAL === */ +@font-face { + font-family: Whitney; + src: url(https://discordapp.com/assets/6c6374bad0b0b6d204d8d6dc4a18d820.woff); + font-weight: 300; +} + +@font-face { + font-family: Whitney; + src: url(https://discordapp.com/assets/e8acd7d9bf6207f99350ca9f9e23b168.woff); + font-weight: 400; +} + +@font-face { + font-family: Whitney; + src: url(https://discordapp.com/assets/3bdef1251a424500c1b3a78dea9b7e57.woff); + font-weight: 500; +} + +@font-face { + font-family: Whitney; + src: url(https://discordapp.com/assets/be0060dafb7a0e31d2a1ca17c0708636.woff); + font-weight: 600; +} + +@font-face { + font-family: Whitney; + src: url(https://discordapp.com/assets/8e12fb4f14d9c4592eb8ec9f22337b04.woff); + font-weight: 700; +} + body { font-family: "Whitney", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; @@ -41,6 +71,7 @@ img { .pre--inline { padding: 2px; border-radius: 3px; + font-size: 85%; } .mention { @@ -289,7 +320,7 @@ img { } .chatlog__embed-footer-text { - font-weight: 600; + font-weight: 500; font-size: .75em; } @@ -309,4 +340,17 @@ img { min-width: 9px; margin-left: 6px; font-size: .875em; +} + +.chatlog__bot-tag { + margin-left: 0.3em; + background: #7289da; + color: #ffffff; + font-size: 0.625em; + padding: 1px 2px; + border-radius: 3px; + vertical-align: middle; + line-height: 1.3; + position: relative; + top: -.2em; } \ No newline at end of file diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html index f5b33b5..1243306 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html @@ -68,6 +68,9 @@
{{~ # Author name and timestamp ~}} {{ group.Author.Name | html.escape }} + {{~ if group.Author.IsBot ~}} + BOT + {{~ end ~}} {{ group.Timestamp | FormatDate | html.escape }} {{~ # Messages ~}} diff --git a/DiscordChatExporter.Core.Services/DataService.Parsers.cs b/DiscordChatExporter.Core.Services/DataService.Parsers.cs index 1d8cea4..d008c11 100644 --- a/DiscordChatExporter.Core.Services/DataService.Parsers.cs +++ b/DiscordChatExporter.Core.Services/DataService.Parsers.cs @@ -16,8 +16,9 @@ namespace DiscordChatExporter.Core.Services var discriminator = json["discriminator"].Value(); var name = json["username"].Value(); var avatarHash = json["avatar"].Value(); + var isBot = json["bot"]?.Value() ?? false; - return new User(id, discriminator, name, avatarHash); + return new User(id, discriminator, name, avatarHash, isBot); } private Guild ParseGuild(JToken json)