mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-11 00:07:55 +00:00
implement the rest of the config commands
This commit is contained in:
parent
a268f75d32
commit
0f26a69f1b
11 changed files with 480 additions and 296 deletions
|
|
@ -101,6 +101,14 @@ public static class ContextParametersExt
|
|||
);
|
||||
}
|
||||
|
||||
public static async Task<SystemConfig.ProxySwitchAction?> ParamResolveProxySwitchAction(this Context ctx, string param_name)
|
||||
{
|
||||
return await ctx.Parameters.ResolveParameter(
|
||||
ctx, param_name,
|
||||
param => (param as Parameter.ProxySwitchAction)?.action
|
||||
);
|
||||
}
|
||||
|
||||
public static async Task<bool?> ParamResolveToggle(this Context ctx, string param_name)
|
||||
{
|
||||
return await ctx.Parameters.ResolveParameter(
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public abstract record Parameter()
|
|||
public record Opaque(string value): Parameter;
|
||||
public record Number(int value): Parameter;
|
||||
public record Avatar(ParsedImage avatar): Parameter;
|
||||
public record ProxySwitchAction(SystemConfig.ProxySwitchAction action): Parameter;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
|
|
@ -122,6 +123,19 @@ public class Parameters
|
|||
return new Parameter.SystemPrivacyTarget(systemPrivacy);
|
||||
case uniffi.commands.Parameter.PrivacyLevel privacyLevel:
|
||||
return new Parameter.PrivacyLevel(privacyLevel.level == "public" ? PrivacyLevel.Public : privacyLevel.level == "private" ? PrivacyLevel.Private : throw new PKError($"Invalid privacy level {privacyLevel.level}"));
|
||||
case uniffi.commands.Parameter.ProxySwitchAction(var action):
|
||||
SystemConfig.ProxySwitchAction newVal;
|
||||
|
||||
if (action.Equals("off", StringComparison.InvariantCultureIgnoreCase))
|
||||
newVal = SystemConfig.ProxySwitchAction.Off;
|
||||
else if (action.Equals("new", StringComparison.InvariantCultureIgnoreCase) || action.Equals("n", StringComparison.InvariantCultureIgnoreCase) || action.Equals("on", StringComparison.InvariantCultureIgnoreCase))
|
||||
newVal = SystemConfig.ProxySwitchAction.New;
|
||||
else if (action.Equals("add", StringComparison.InvariantCultureIgnoreCase) || action.Equals("a", StringComparison.InvariantCultureIgnoreCase))
|
||||
newVal = SystemConfig.ProxySwitchAction.Add;
|
||||
else
|
||||
throw new PKError("You must pass either \"new\", \"add\", or \"off\" to this command.");
|
||||
|
||||
return new Parameter.ProxySwitchAction(newVal);
|
||||
case uniffi.commands.Parameter.Toggle toggle:
|
||||
return new Parameter.Toggle(toggle.toggle);
|
||||
case uniffi.commands.Parameter.OpaqueString opaque:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue