mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-29 17:23:04 +00:00
Add support for Guild Member object & included data (#279)
This commit is contained in:
@@ -75,6 +75,10 @@ namespace DiscordChatExporter.Core.Rendering.Formatters
|
||||
scriptObject.Import("FormatMarkdown",
|
||||
new Func<string, string>(m => HtmlRenderingLogic.FormatMarkdown(Context, m)));
|
||||
|
||||
scriptObject.Import("GetUserColor", new Func<Guild, User, string>(Guild.GetUserColor));
|
||||
|
||||
scriptObject.Import("GetUserNick", new Func<Guild, User, string>(Guild.GetUserNick));
|
||||
|
||||
// Push model
|
||||
templateContext.PushGlobal(scriptObject);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -114,8 +115,9 @@ namespace DiscordChatExporter.Core.Rendering.Logic
|
||||
{
|
||||
var role = context.MentionableRoles.FirstOrDefault(r => r.Id == mentionNode.Id) ??
|
||||
Role.CreateDeletedRole(mentionNode.Id);
|
||||
|
||||
return $"<span class=\"mention\">@{HtmlEncode(role.Name)}</span>";
|
||||
string style = "";
|
||||
if (role.Color != Color.Black) style = $"style=\"color: {role.ColorAsHex}; background-color: rgba({role.ColorAsRgb}, 0.1); font-weight: 400;\"";
|
||||
return $"<span class=\"mention\" {style}>@{HtmlEncode(role.Name)}</span>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</div>
|
||||
<div class="chatlog__messages">
|
||||
{{~ # Author name and timestamp ~}}
|
||||
<span class="chatlog__author-name" title="{{ MessageGroup.Author.FullName | html.escape }}" data-user-id="{{ MessageGroup.Author.Id | html.escape }}">{{ MessageGroup.Author.Name | html.escape }}</span>
|
||||
<span class="chatlog__author-name" title="{{ MessageGroup.Author.FullName | html.escape }}" data-user-id="{{ MessageGroup.Author.Id | html.escape }}" style="color: {{ GetUserColor Context.Guild MessageGroup.Author }}">{{ GetUserNick Context.Guild MessageGroup.Author | html.escape }}</span>
|
||||
|
||||
{{~ # Bot tag ~}}
|
||||
{{~ if MessageGroup.Author.IsBot ~}}
|
||||
|
||||
Reference in New Issue
Block a user