2021-08-27 15:03:47 +00:00
|
|
|
#nullable enable
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.Core;
|
2020-06-12 21:13:21 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Model for the `proxy_members` PL/pgSQL function in `functions.sql`
|
|
|
|
/// </summary>
|
|
|
|
public class ProxyMember
|
2020-06-12 21:13:21 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
public ProxyMember() { }
|
|
|
|
|
|
|
|
public ProxyMember(string name, params ProxyTag[] tags)
|
|
|
|
{
|
|
|
|
Name = name;
|
|
|
|
ProxyTags = tags;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MemberId Id { get; }
|
|
|
|
public IReadOnlyCollection<ProxyTag> ProxyTags { get; } = new ProxyTag[0];
|
|
|
|
public bool KeepProxy { get; }
|
|
|
|
|
|
|
|
public string? ServerName { get; }
|
|
|
|
public string? DisplayName { get; }
|
|
|
|
public string Name { get; } = "";
|
|
|
|
|
|
|
|
public string? ServerAvatar { get; }
|
|
|
|
public string? Avatar { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public bool AllowAutoproxy { get; }
|
|
|
|
public string? Color { get; }
|
|
|
|
|
|
|
|
public string ProxyName(MessageContext ctx)
|
2020-06-12 21:13:21 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
var memberName = ServerName ?? DisplayName ?? Name;
|
|
|
|
if (!ctx.TagEnabled)
|
|
|
|
return memberName;
|
|
|
|
|
|
|
|
if (ctx.SystemGuildTag != null)
|
|
|
|
return $"{memberName} {ctx.SystemGuildTag}";
|
|
|
|
if (ctx.SystemTag != null)
|
|
|
|
return $"{memberName} {ctx.SystemTag}";
|
|
|
|
return memberName;
|
2020-06-12 21:13:21 +00:00
|
|
|
}
|
2021-11-27 02:10:56 +00:00
|
|
|
|
|
|
|
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? Avatar ?? ctx.SystemAvatar;
|
2020-06-12 21:13:21 +00:00
|
|
|
}
|