2021-08-27 11:03:47 -04:00
|
|
|
#nullable enable
|
2020-06-11 23:20:46 +02:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
namespace PluralKit.Bot;
|
|
|
|
|
|
|
|
|
|
public struct ProxyMatch
|
2020-06-11 23:20:46 +02:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
public ProxyMember Member;
|
|
|
|
|
public string? Content;
|
|
|
|
|
public ProxyTag? ProxyTags;
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2023-08-10 18:15:25 +12:00
|
|
|
private bool ShouldKeepProxy()
|
|
|
|
|
{
|
|
|
|
|
if (Member.ServerKeepProxy != null && Member.ServerKeepProxy.Value)
|
|
|
|
|
return true;
|
|
|
|
|
else if (Member.KeepProxy && !(Member.ServerKeepProxy != null && !Member.ServerKeepProxy.Value))
|
|
|
|
|
return true;
|
|
|
|
|
else return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
public string? ProxyContent
|
|
|
|
|
{
|
|
|
|
|
get
|
2020-06-11 23:20:46 +02:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
// Add the proxy tags into the proxied message if that option is enabled
|
|
|
|
|
// Also check if the member has any proxy tags - some cases autoproxy can return a member with no tags
|
2023-08-10 18:15:25 +12:00
|
|
|
if (ShouldKeepProxy() && ProxyTags != null && Content != null)
|
2021-11-26 21:10:56 -05:00
|
|
|
return $"{ProxyTags.Value.Prefix}{Content}{ProxyTags.Value.Suffix}";
|
2020-06-11 23:20:46 +02:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
return Content;
|
2020-06-11 23:20:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|