feat(bot): add option for hid capitalization

This commit is contained in:
Iris System 2024-04-28 21:05:46 +12:00
parent a3f1601938
commit 1ce9227b7d
7 changed files with 44 additions and 2 deletions

View file

@ -540,6 +540,8 @@ public partial class CommandTree
return ctx.Execute<Config>(null, m => m.ProxyErrorMessageEnabled(ctx));
if (ctx.MatchMultiple(new[] { "split" }, new[] { "id", "ids" }) || ctx.Match("sid"))
return ctx.Execute<Config>(null, m => m.HidDisplaySplit(ctx));
if (ctx.MatchMultiple(new[] { "caps", "capitalize", "capitalise" }, new[] { "id", "ids" }) || ctx.Match("capid"))
return ctx.Execute<Config>(null, m => m.HidDisplayCaps(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

@ -109,6 +109,13 @@ public class Config
"disabled"
));
items.Add(new(
"Capitalize IDs",
"Whether to display IDs as capital letters, to ease readability",
EnabledDisabled(ctx.Config.HidDisplayCaps),
"disabled"
));
await ctx.Paginate<PaginatedConfigItem>(
items.ToAsyncEnumerable(),
items.Count,
@ -464,4 +471,18 @@ public class Config
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)}.");
}
public async Task HidDisplayCaps(Context ctx)
{
if (!ctx.HasNext())
{
var msg = $"Displaying IDs as capital letters is currently **{EnabledDisabled(ctx.Config.HidDisplayCaps)}**.";
await ctx.Reply(msg);
return;
}
var newVal = ctx.MatchToggle(true);
await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { HidDisplayCaps = newVal });
await ctx.Reply($"Displaying IDs as capital letters is now {EnabledDisabled(newVal)}.");
}
}

View file

@ -31,7 +31,12 @@ public static class ModelUtils
public static string DisplayHid(this PKSystem system, SystemConfig? cfg = null) => HidTransform(system.Hid, cfg);
public static string DisplayHid(this PKGroup group, SystemConfig? cfg = null) => HidTransform(group.Hid, cfg);
public static string DisplayHid(this PKMember member, SystemConfig? cfg = null) => HidTransform(member.Hid, cfg);
private static string HidTransform(string hid, SystemConfig? cfg = null) => HidUtils.HidTransform(hid, cfg != null && cfg.HidDisplaySplit);
private static string HidTransform(string hid, SystemConfig? cfg = null) =>
HidUtils.HidTransform(
hid,
cfg != null && cfg.HidDisplaySplit,
cfg != null && cfg.HidDisplayCaps
);
private static string EntityReference(string hid, string name)
{