PluralKit/PluralKit.Core/Database/Functions/ProxyMember.cs

48 lines
1.4 KiB
C#
Raw Normal View History

#nullable enable
using System.Collections.Generic;
namespace PluralKit.Core
{
/// <summary>
/// Model for the `proxy_members` PL/pgSQL function in `functions.sql`
/// </summary>
public class ProxyMember
{
2020-06-14 19:37:04 +00:00
public MemberId Id { get; }
2020-06-12 22:42:25 +00:00
public IReadOnlyCollection<ProxyTag> ProxyTags { get; } = new ProxyTag[0];
public bool KeepProxy { get; }
2020-06-12 22:42:25 +00:00
public string? ServerName { get; }
public string? DisplayName { get; }
public string Name { get; } = "";
2020-06-12 22:42:25 +00:00
public string? ServerAvatar { get; }
public string? Avatar { get; }
2021-05-01 18:20:00 +00:00
public bool AllowAutoproxy { get; }
2021-05-01 18:20:00 +00:00
public string? Color { get; }
2021-08-02 21:22:06 +00:00
public string ProxyName(MessageContext ctx)
{
var memberName = ServerName ?? DisplayName ?? Name;
if (!ctx.TagEnabled)
return memberName;
2021-08-02 21:22:06 +00:00
if (ctx.SystemGuildTag != null)
return $"{memberName} {ctx.SystemGuildTag}";
else if (ctx.SystemTag != null)
return $"{memberName} {ctx.SystemTag}";
else return memberName;
}
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? Avatar ?? ctx.SystemAvatar;
public ProxyMember() { }
public ProxyMember(string name, params ProxyTag[] tags)
{
Name = name;
ProxyTags = tags;
}
}
}