feat: guild-specific name format

This commit is contained in:
rladenson 2024-11-19 17:35:09 -07:00 committed by Petal Ladenson
parent da4c05d4ed
commit ec6cbb2a64
11 changed files with 75 additions and 5 deletions

View file

@ -27,6 +27,7 @@ public class MessageContext
public string? SystemGuildTag { get; }
public bool TagEnabled { get; }
public string? NameFormat { get; }
public string? GuildNameFormat { get; }
public string? SystemAvatar { get; }
public string? SystemGuildAvatar { get; }
public bool AllowAutoproxy { get; }

View file

@ -9,7 +9,7 @@ public static class MessageContextExt
if (!ctx.TagEnabled || tag == null)
return false;
var format = ctx.NameFormat ?? ProxyMember.DefaultFormat;
var format = ctx.GuildNameFormat ?? ctx.NameFormat ?? ProxyMember.DefaultFormat;
if (!format.Contains("{tag}"))
return false;

View file

@ -45,7 +45,7 @@ public class ProxyMember
var tag = ctx.SystemGuildTag ?? ctx.SystemTag;
if (!ctx.TagEnabled) tag = null;
return FormatTag(ctx.NameFormat ?? DefaultFormat, tag, memberName);
return FormatTag(ctx.GuildNameFormat ?? ctx.NameFormat ?? DefaultFormat, tag, memberName);
}
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? WebhookAvatar ?? Avatar ?? ctx.SystemGuildAvatar ?? ctx.SystemAvatar;

View file

@ -16,6 +16,7 @@ create function message_context(account_id bigint, guild_id bigint, channel_id b
proxy_enabled bool,
system_guild_tag text,
system_guild_avatar text,
guild_name_format text,
last_switch int,
last_switch_members int[],
@ -51,6 +52,7 @@ as $$
coalesce(system_guild.proxy_enabled, true) as proxy_enabled,
system_guild.tag as system_guild_tag,
system_guild.avatar_url as system_guild_avatar,
system_guild.name_format as guild_name_format,
-- system_last_switch view
system_last_switch.switch as last_switch,