Merge branch 'main' into banner_privacy

This commit is contained in:
violet 2024-11-09 10:42:58 -08:00 committed by GitHub
commit a793c6ea52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 52 additions and 5 deletions

View file

@ -596,6 +596,8 @@ public partial class CommandTree
return ctx.Execute<Config>(null, m => m.HidListPadding(ctx));
if (ctx.MatchMultiple(new[] { "member", "group" }, new[] { "limit" }) || ctx.Match("limit"))
return ctx.Execute<Config>(null, m => m.LimitUpdate(ctx));
if (ctx.MatchMultiple(new[] { "proxy" }, new[] { "switch" }) || ctx.Match("proxyswitch", "ps"))
return ctx.Execute<Config>(null, m => m.ProxySwitch(ctx));
// todo: maybe add the list of configuration keys here?
return ctx.Reply($"{Emojis.Error} Could not find a setting with that name. Please see `pk;commands config` for the list of possible config settings.");

View file

@ -123,6 +123,13 @@ public class Config
"off"
));
items.Add(new(
"Proxy Switch",
"Whether using a proxy tag logs a switch",
EnabledDisabled(ctx.Config.ProxySwitch),
"disabled"
));
await ctx.Paginate<PaginatedConfigItem>(
items.ToAsyncEnumerable(),
items.Count,
@ -474,7 +481,7 @@ public class Config
return;
}
var newVal = ctx.MatchToggle(true);
var newVal = ctx.MatchToggle(false);
await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { HidDisplaySplit = newVal });
await ctx.Reply($"Splitting of 6-character IDs with a hyphen is now {EnabledDisabled(newVal)}.");
}
@ -488,7 +495,7 @@ public class Config
return;
}
var newVal = ctx.MatchToggle(true);
var newVal = ctx.MatchToggle(false);
await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { HidDisplayCaps = newVal });
await ctx.Reply($"Displaying IDs as capital letters is now {EnabledDisabled(newVal)}.");
}
@ -537,6 +544,20 @@ public class Config
else throw new PKError(badInputError);
}
public async Task ProxySwitch(Context ctx)
{
if (!ctx.HasNext())
{
var msg = $"Logging a switch every time a proxy tag is used is currently **{EnabledDisabled(ctx.Config.ProxySwitch)}**.";
await ctx.Reply(msg);
return;
}
var newVal = ctx.MatchToggle(false);
await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { ProxySwitch = newVal });
await ctx.Reply($"Logging a switch every time a proxy tag is used is now {EnabledDisabled(newVal)}.");
}
public Task LimitUpdate(Context ctx)
{
throw new PKError("You cannot update your own member or group limits. If you need a limit update, please join the " +

View file

@ -432,7 +432,7 @@ public class ProxiedMessage
return;
}
await ctx.Reply(embed: await _embeds.CreateMessageInfoEmbed(message, showContent));
await ctx.Reply(embed: await _embeds.CreateMessageInfoEmbed(message, showContent, ctx.Config));
}
private async Task DeleteCommandMessage(Context ctx, ulong messageId)

View file

@ -506,6 +506,10 @@ public class ProxyService
Task DispatchWebhook() => _dispatch.Dispatch(ctx.SystemId.Value, sentMessage);
Task MaybeLogSwitch() => (ctx.ProxySwitch && !Array.Exists(ctx.LastSwitchMembers, element => element == match.Member.Id))
? _db.Execute(conn => _repo.AddSwitch(conn, (SystemId)ctx.SystemId, new[] { match.Member.Id }))
: Task.CompletedTask;
async Task DeleteProxyTriggerMessage()
{
if (!deletePrevious)
@ -539,7 +543,8 @@ public class ProxyService
UpdateMemberForSentMessage(),
LogMessageToChannel(),
SaveLatchAutoproxy(),
DispatchWebhook()
DispatchWebhook(),
MaybeLogSwitch()
);
}