feat: upgrade to .NET 6, refactor everything
This commit is contained in:
@@ -2,31 +2,30 @@
|
||||
|
||||
using NodaTime;
|
||||
|
||||
namespace PluralKit.Core
|
||||
namespace PluralKit.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Model for the `message_context` PL/pgSQL function in `functions.sql`
|
||||
/// </summary>
|
||||
public class MessageContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Model for the `message_context` PL/pgSQL function in `functions.sql`
|
||||
/// </summary>
|
||||
public class MessageContext
|
||||
{
|
||||
public SystemId? SystemId { get; }
|
||||
public ulong? LogChannel { get; }
|
||||
public bool InBlacklist { get; }
|
||||
public bool InLogBlacklist { get; }
|
||||
public bool LogCleanupEnabled { get; }
|
||||
public bool ProxyEnabled { get; }
|
||||
public AutoproxyMode AutoproxyMode { get; }
|
||||
public MemberId? AutoproxyMember { get; }
|
||||
public ulong? LastMessage { get; }
|
||||
public MemberId? LastMessageMember { get; }
|
||||
public SwitchId? LastSwitch { get; }
|
||||
public MemberId[] LastSwitchMembers { get; } = new MemberId[0];
|
||||
public Instant? LastSwitchTimestamp { get; }
|
||||
public string? SystemTag { get; }
|
||||
public string? SystemGuildTag { get; }
|
||||
public bool TagEnabled { get; }
|
||||
public string? SystemAvatar { get; }
|
||||
public bool AllowAutoproxy { get; }
|
||||
public int? LatchTimeout { get; }
|
||||
}
|
||||
public SystemId? SystemId { get; }
|
||||
public ulong? LogChannel { get; }
|
||||
public bool InBlacklist { get; }
|
||||
public bool InLogBlacklist { get; }
|
||||
public bool LogCleanupEnabled { get; }
|
||||
public bool ProxyEnabled { get; }
|
||||
public AutoproxyMode AutoproxyMode { get; }
|
||||
public MemberId? AutoproxyMember { get; }
|
||||
public ulong? LastMessage { get; }
|
||||
public MemberId? LastMessageMember { get; }
|
||||
public SwitchId? LastSwitch { get; }
|
||||
public MemberId[] LastSwitchMembers { get; } = new MemberId[0];
|
||||
public Instant? LastSwitchTimestamp { get; }
|
||||
public string? SystemTag { get; }
|
||||
public string? SystemGuildTag { get; }
|
||||
public bool TagEnabled { get; }
|
||||
public string? SystemAvatar { get; }
|
||||
public bool AllowAutoproxy { get; }
|
||||
public int? LatchTimeout { get; }
|
||||
}
|
@@ -1,48 +1,46 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
namespace PluralKit.Core;
|
||||
|
||||
namespace PluralKit.Core
|
||||
/// <summary>
|
||||
/// Model for the `proxy_members` PL/pgSQL function in `functions.sql`
|
||||
/// </summary>
|
||||
public class ProxyMember
|
||||
{
|
||||
/// <summary>
|
||||
/// Model for the `proxy_members` PL/pgSQL function in `functions.sql`
|
||||
/// </summary>
|
||||
public class ProxyMember
|
||||
public ProxyMember() { }
|
||||
|
||||
public ProxyMember(string name, params ProxyTag[] 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)
|
||||
{
|
||||
var memberName = ServerName ?? DisplayName ?? Name;
|
||||
if (!ctx.TagEnabled)
|
||||
return memberName;
|
||||
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? Avatar ?? ctx.SystemAvatar;
|
||||
}
|
Reference in New Issue
Block a user