2021-08-27 11:03:47 -04:00
|
|
|
#nullable enable
|
2020-06-12 23:13:21 +02:00
|
|
|
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 21:37:04 +02:00
|
|
|
public MemberId Id { get; }
|
2020-06-13 00:42:25 +02:00
|
|
|
public IReadOnlyCollection<ProxyTag> ProxyTags { get; } = new ProxyTag[0];
|
|
|
|
public bool KeepProxy { get; }
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2020-06-13 00:42:25 +02:00
|
|
|
public string? ServerName { get; }
|
|
|
|
public string? DisplayName { get; }
|
|
|
|
public string Name { get; } = "";
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2020-06-13 00:42:25 +02:00
|
|
|
public string? ServerAvatar { get; }
|
|
|
|
public string? Avatar { get; }
|
2020-06-12 23:24:36 +02:00
|
|
|
|
2021-05-01 19:20:00 +01:00
|
|
|
|
2020-11-20 16:40:36 -05:00
|
|
|
public bool AllowAutoproxy { get; }
|
2021-05-01 19:20:00 +01:00
|
|
|
public string? Color { get; }
|
2020-11-20 16:40:36 -05:00
|
|
|
|
2021-08-02 17:22:06 -04:00
|
|
|
public string ProxyName(MessageContext ctx)
|
|
|
|
{
|
|
|
|
var memberName = ServerName ?? DisplayName ?? Name;
|
|
|
|
if (!ctx.TagEnabled)
|
|
|
|
return memberName;
|
2020-06-12 23:24:36 +02:00
|
|
|
|
2021-08-02 17:22:06 -04:00
|
|
|
if (ctx.SystemGuildTag != null)
|
|
|
|
return $"{memberName} {ctx.SystemGuildTag}";
|
|
|
|
else if (ctx.SystemTag != null)
|
|
|
|
return $"{memberName} {ctx.SystemTag}";
|
|
|
|
else return memberName;
|
|
|
|
}
|
2020-06-12 23:30:10 +02:00
|
|
|
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? Avatar ?? ctx.SystemAvatar;
|
2020-06-14 18:56:53 +02:00
|
|
|
|
|
|
|
public ProxyMember() { }
|
|
|
|
|
|
|
|
public ProxyMember(string name, params ProxyTag[] tags)
|
|
|
|
{
|
|
|
|
Name = name;
|
|
|
|
ProxyTags = tags;
|
|
|
|
}
|
2020-06-12 23:13:21 +02:00
|
|
|
}
|
|
|
|
}
|