721a4502bb
* Some reasons this needs to exist for it to run on my machine? I don't think it would hurt to have it in other machines so * Add options to member model * Add Privacy to member embed * Added member privacy display list * Update database settings * apparetnly this is nolonger needed? * Fix sql call * Fix more sql errors * Added in settings control * Add all subject to system privacy * Basic API Privacy * Name privacy in logs * update todo * remove CheckReadMemberPermission * Added name privacy to log embed * update todo * Update todo * Update api to handle privacy * update todo * Update systemlist full to respect privacy (as well as system list) * include colour as option for member privacy subject * move todo file (why was it there?) * Update TODO.md * Update TODO.md * Update TODO.md * Deleted to create pr * Update command usage and add to the command tree * Make api respect created privacy * Add editing privacy through the api * Fix pronoun privacy field in api * Fix info leak of display name in api * deprecate privacy field in api * Deprecate privacy diffrently * Update API * Update documentation * Update documentation * Remove comment in yml * Update userguide * Update migration (fix typo in 5.sql too) * Sanatize names * some full stops * Fix after merge * update migration * update schema version * update edit command * update privacy filter * fix a dumb mistake * clarify on what name privacy does * make it easier on someone else * Update docs * Comment out unused code * Add aliases for `member privacy all public` and `member privacy all private`
60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
using DSharpPlus.Entities;
|
|
|
|
using NodaTime;
|
|
|
|
using PluralKit.Core;
|
|
|
|
namespace PluralKit.Bot
|
|
{
|
|
public class ShortRenderer: IListRenderer
|
|
{
|
|
public int MembersPerPage => 25;
|
|
|
|
public void RenderPage(DiscordEmbedBuilder eb, DateTimeZone timezone, IEnumerable<ListedMember> members, LookupContext ctx)
|
|
{
|
|
string RenderLine(ListedMember m)
|
|
{
|
|
if (m.HasProxyTags)
|
|
{
|
|
var proxyTagsString = m.ProxyTagsString().SanitizeMentions();
|
|
if (proxyTagsString.Length > 100) // arbitrary threshold for now, tweak?
|
|
proxyTagsString = "tags too long, see member card";
|
|
var memberName = m.NamePrivacy.CanAccess(ctx) ? m.Name : (m.DisplayName ?? m.Name);
|
|
return $"[`{m.Hid}`] **{memberName.SanitizeMentions()}** *({proxyTagsString})*";
|
|
}
|
|
|
|
return $"[`{m.Hid}`] **{m.Name.SanitizeMentions()}**";
|
|
}
|
|
|
|
var buf = new StringBuilder();
|
|
var chunks = new List<string>();
|
|
|
|
// Split the list into properly-sized chunks
|
|
foreach (var m in members)
|
|
{
|
|
var line = RenderLine(m);
|
|
|
|
// First chunk goes in description (2048 chars), rest go in embed values (1000 chars)
|
|
var lengthLimit = chunks.Count == 0 ? 2048 : 1000;
|
|
if (buf.Length + line.Length + 1 > lengthLimit)
|
|
{
|
|
chunks.Add(buf.ToString());
|
|
buf.Clear();
|
|
}
|
|
|
|
buf.Append(RenderLine(m));
|
|
buf.Append("\n");
|
|
}
|
|
chunks.Add(buf.ToString());
|
|
|
|
// Put the first chunk in the description, rest in blank-name embed fields
|
|
eb.Description = chunks[0];
|
|
for (var i = 1; i < chunks.Count; i++)
|
|
// Field name is Unicode zero-width space
|
|
eb.AddField("\u200B", chunks[i]);
|
|
}
|
|
}
|
|
} |