mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: public/private lookup flags, consistency
This commit is contained in:
parent
aacf5909a9
commit
455830a2b5
16 changed files with 44 additions and 40 deletions
|
|
@ -133,14 +133,29 @@ public class Context
|
|||
await Reply($"{Emojis.Warn} This command is deprecated and will be removed soon. In the future, please use `pk;{commandDef.Key}`.");
|
||||
}
|
||||
|
||||
public LookupContext LookupContextFor(PKSystem target) =>
|
||||
System?.Id == target.Id ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
public LookupContext LookupContextFor(SystemId systemId)
|
||||
{
|
||||
var hasPrivateOverride = this.MatchFlag("private", "priv");
|
||||
var hasPublicOverride = this.MatchFlag("public", "pub");
|
||||
|
||||
public LookupContext LookupContextFor(SystemId systemId) =>
|
||||
System?.Id == systemId ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
if (hasPrivateOverride && hasPublicOverride)
|
||||
throw new PKError("Cannot match both public and private flags at the same time.");
|
||||
|
||||
public LookupContext LookupContextFor(PKMember target) =>
|
||||
System?.Id == target.System ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
if (System.Id != systemId)
|
||||
{
|
||||
if (hasPrivateOverride)
|
||||
throw Errors.NotOwnInfo;
|
||||
return LookupContext.ByNonOwner;
|
||||
}
|
||||
|
||||
if (hasPrivateOverride)
|
||||
return LookupContext.ByOwner;
|
||||
if (hasPublicOverride)
|
||||
return LookupContext.ByNonOwner;
|
||||
|
||||
// todo: add config defaults
|
||||
return LookupContext.ByOwner;
|
||||
}
|
||||
|
||||
public IComponentContext Services => _provider;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue