mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(bot): add toggle for color codes on cv2 cards
Some checks failed
Build dashboard Docker image / dashboard docker build (push) Has been cancelled
Build and push Docker image / .net docker build (push) Has been cancelled
Build and push Rust service Docker images / rust docker build (push) Has been cancelled
rust checks / cargo fmt (push) Has been cancelled
Some checks failed
Build dashboard Docker image / dashboard docker build (push) Has been cancelled
Build and push Docker image / .net docker build (push) Has been cancelled
Build and push Rust service Docker images / rust docker build (push) Has been cancelled
rust checks / cargo fmt (push) Has been cancelled
This commit is contained in:
parent
da42ba9d21
commit
ac845d7b5a
7 changed files with 50 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ reqwest = { version = "0.12.7" , default-features = false, features = ["rustls-t
|
||||||
sentry = { version = "0.36.0", default-features = false, features = ["backtrace", "contexts", "panic", "debug-images", "reqwest", "rustls"] } # replace native-tls with rustls
|
sentry = { version = "0.36.0", default-features = false, features = ["backtrace", "contexts", "panic", "debug-images", "reqwest", "rustls"] } # replace native-tls with rustls
|
||||||
serde = { version = "1.0.196", features = ["derive"] }
|
serde = { version = "1.0.196", features = ["derive"] }
|
||||||
serde_json = "1.0.117"
|
serde_json = "1.0.117"
|
||||||
sqlx = { version = "0.8.2", features = ["runtime-tokio", "postgres", "time", "macros", "uuid"] }
|
sqlx = { version = "0.8.2", features = ["runtime-tokio", "postgres", "time", "chrono", "macros", "uuid"] }
|
||||||
tokio = { version = "1.36.0", features = ["full"] }
|
tokio = { version = "1.36.0", features = ["full"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "json"] }
|
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "json"] }
|
||||||
|
|
|
||||||
|
|
@ -592,6 +592,8 @@ public partial class CommandTree
|
||||||
return ctx.Execute<Config>(null, m => m.HidDisplayCaps(ctx));
|
return ctx.Execute<Config>(null, m => m.HidDisplayCaps(ctx));
|
||||||
if (ctx.MatchMultiple(new[] { "pad" }, new[] { "id", "ids" }) || ctx.MatchMultiple(new[] { "id" }, new[] { "pad", "padding" }) || ctx.Match("idpad", "padid", "padids"))
|
if (ctx.MatchMultiple(new[] { "pad" }, new[] { "id", "ids" }) || ctx.MatchMultiple(new[] { "id" }, new[] { "pad", "padding" }) || ctx.Match("idpad", "padid", "padids"))
|
||||||
return ctx.Execute<Config>(null, m => m.HidListPadding(ctx));
|
return ctx.Execute<Config>(null, m => m.HidListPadding(ctx));
|
||||||
|
if (ctx.MatchMultiple(new[] { "show" }, new[] { "color", "colour", "colors", "colours" }) || ctx.Match("showcolor", "showcolour", "showcolors", "showcolours", "colorcode", "colorhex"))
|
||||||
|
return ctx.Execute<Config>(null, m => m.CardShowColorHex(ctx));
|
||||||
if (ctx.MatchMultiple(new[] { "name" }, new[] { "format" }) || ctx.Match("nameformat", "nf"))
|
if (ctx.MatchMultiple(new[] { "name" }, new[] { "format" }) || ctx.Match("nameformat", "nf"))
|
||||||
return ctx.Execute<Config>(null, m => m.NameFormat(ctx));
|
return ctx.Execute<Config>(null, m => m.NameFormat(ctx));
|
||||||
if (ctx.MatchMultiple(new[] { "member", "group" }, new[] { "limit" }) || ctx.Match("limit"))
|
if (ctx.MatchMultiple(new[] { "member", "group" }, new[] { "limit" }) || ctx.Match("limit"))
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,13 @@ public class Config
|
||||||
"off"
|
"off"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
items.Add(new(
|
||||||
|
"show color",
|
||||||
|
"Whether to show color codes in system/member/group cards",
|
||||||
|
EnabledDisabled(ctx.Config.CardShowColorHex),
|
||||||
|
"disabled"
|
||||||
|
));
|
||||||
|
|
||||||
items.Add(new(
|
items.Add(new(
|
||||||
"Proxy Switch",
|
"Proxy Switch",
|
||||||
"Switching behavior when proxy tags are used",
|
"Switching behavior when proxy tags are used",
|
||||||
|
|
@ -570,6 +577,20 @@ public class Config
|
||||||
else throw new PKError(badInputError);
|
else throw new PKError(badInputError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task CardShowColorHex(Context ctx)
|
||||||
|
{
|
||||||
|
if (!ctx.HasNext())
|
||||||
|
{
|
||||||
|
var msg = $"Showing color codes on system/member/group cards is currently **{EnabledDisabled(ctx.Config.CardShowColorHex)}**.";
|
||||||
|
await ctx.Reply(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newVal = ctx.MatchToggle(false);
|
||||||
|
await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { CardShowColorHex = newVal });
|
||||||
|
await ctx.Reply($"Showing color codes on system/member/group cards is now {EnabledDisabled(newVal)}.");
|
||||||
|
}
|
||||||
|
|
||||||
public async Task ProxySwitch(Context ctx)
|
public async Task ProxySwitch(Context ctx)
|
||||||
{
|
{
|
||||||
if (!ctx.HasNext())
|
if (!ctx.HasNext())
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,15 @@ public class EmbedService
|
||||||
if (system.Tag != null)
|
if (system.Tag != null)
|
||||||
headerText += $"\n**Tag:** {system.Tag.EscapeMarkdown()}";
|
headerText += $"\n**Tag:** {system.Tag.EscapeMarkdown()}";
|
||||||
|
|
||||||
|
if (cctx.Config.CardShowColorHex && !system.Color.EmptyOrNull())
|
||||||
|
headerText += $"\n**Color:** #{system.Color}";
|
||||||
|
|
||||||
if (cctx.Guild != null)
|
if (cctx.Guild != null)
|
||||||
{
|
{
|
||||||
if (guildSettings.Tag != null && guildSettings.TagEnabled)
|
if (guildSettings.Tag != null && guildSettings.TagEnabled)
|
||||||
headerText += $"**Tag (in server '{cctx.Guild.Name}'):** {guildSettings.Tag.EscapeMarkdown()}";
|
headerText += $"\n**Tag (in server '{cctx.Guild.Name}'):** {guildSettings.Tag.EscapeMarkdown()}";
|
||||||
if (!guildSettings.TagEnabled)
|
if (!guildSettings.TagEnabled)
|
||||||
headerText += $"**Tag (in server '{cctx.Guild.Name}'):** *(tag is disabled in this server)*";
|
headerText += $"\n**Tag (in server '{cctx.Guild.Name}'):** *(tag is disabled in this server)*";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (system.MemberListPrivacy.CanAccess(ctx))
|
if (system.MemberListPrivacy.CanAccess(ctx))
|
||||||
|
|
@ -358,6 +361,8 @@ public class EmbedService
|
||||||
headerText += $"\n**Display name:** {member.DisplayName.Truncate(1024)}";
|
headerText += $"\n**Display name:** {member.DisplayName.Truncate(1024)}";
|
||||||
if (guild != null && guildDisplayName != null)
|
if (guild != null && guildDisplayName != null)
|
||||||
headerText += $"\n**Server nickname (for '{guild.Name}'):** {guildDisplayName.Truncate(1024)}";
|
headerText += $"\n**Server nickname (for '{guild.Name}'):** {guildDisplayName.Truncate(1024)}";
|
||||||
|
if (ccfg.CardShowColorHex && !member.Color.EmptyOrNull())
|
||||||
|
headerText += $"\n**Color:** #{member.Color}";
|
||||||
if (member.PronounsFor(ctx) is { } pronouns && !string.IsNullOrWhiteSpace(pronouns))
|
if (member.PronounsFor(ctx) is { } pronouns && !string.IsNullOrWhiteSpace(pronouns))
|
||||||
headerText += $"\n**Pronouns:** {pronouns}";
|
headerText += $"\n**Pronouns:** {pronouns}";
|
||||||
if (member.BirthdayFor(ctx) != null)
|
if (member.BirthdayFor(ctx) != null)
|
||||||
|
|
@ -577,6 +582,9 @@ public class EmbedService
|
||||||
if (target.NamePrivacy.CanAccess(pctx) && target.DisplayName != null)
|
if (target.NamePrivacy.CanAccess(pctx) && target.DisplayName != null)
|
||||||
headerText += $"\n**Display name:** {target.DisplayName}";
|
headerText += $"\n**Display name:** {target.DisplayName}";
|
||||||
|
|
||||||
|
if (ctx.Config.CardShowColorHex && !target.Color.EmptyOrNull())
|
||||||
|
headerText += $"\n**Color:** #{target.Color}";
|
||||||
|
|
||||||
if (target.ListPrivacy.CanAccess(pctx))
|
if (target.ListPrivacy.CanAccess(pctx))
|
||||||
{
|
{
|
||||||
headerText += $"\n**Members:** {memberCount}";
|
headerText += $"\n**Members:** {memberCount}";
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public class SystemConfigPatch: PatchObject
|
||||||
public Partial<bool> ProxyErrorMessageEnabled { get; set; }
|
public Partial<bool> ProxyErrorMessageEnabled { get; set; }
|
||||||
public Partial<bool> HidDisplaySplit { get; set; }
|
public Partial<bool> HidDisplaySplit { get; set; }
|
||||||
public Partial<bool> HidDisplayCaps { get; set; }
|
public Partial<bool> HidDisplayCaps { get; set; }
|
||||||
|
public Partial<bool> CardShowColorHex { get; set; }
|
||||||
public Partial<string?> NameFormat { get; set; }
|
public Partial<string?> NameFormat { get; set; }
|
||||||
public Partial<SystemConfig.HidPadFormat> HidListPadding { get; set; }
|
public Partial<SystemConfig.HidPadFormat> HidListPadding { get; set; }
|
||||||
public Partial<SystemConfig.ProxySwitchAction> ProxySwitch { get; set; }
|
public Partial<SystemConfig.ProxySwitchAction> ProxySwitch { get; set; }
|
||||||
|
|
@ -41,6 +42,7 @@ public class SystemConfigPatch: PatchObject
|
||||||
.With("hid_display_split", HidDisplaySplit)
|
.With("hid_display_split", HidDisplaySplit)
|
||||||
.With("hid_display_caps", HidDisplayCaps)
|
.With("hid_display_caps", HidDisplayCaps)
|
||||||
.With("hid_list_padding", HidListPadding)
|
.With("hid_list_padding", HidListPadding)
|
||||||
|
.With("card_show_color_hex", CardShowColorHex)
|
||||||
.With("proxy_switch", ProxySwitch)
|
.With("proxy_switch", ProxySwitch)
|
||||||
.With("name_format", NameFormat)
|
.With("name_format", NameFormat)
|
||||||
);
|
);
|
||||||
|
|
@ -107,6 +109,9 @@ public class SystemConfigPatch: PatchObject
|
||||||
if (HidListPadding.IsPresent)
|
if (HidListPadding.IsPresent)
|
||||||
o.Add("hid_list_padding", HidListPadding.Value.ToUserString());
|
o.Add("hid_list_padding", HidListPadding.Value.ToUserString());
|
||||||
|
|
||||||
|
if (CardShowColorHex.IsPresent)
|
||||||
|
o.Add("card_show_color_hex", CardShowColorHex.Value);
|
||||||
|
|
||||||
if (ProxySwitch.IsPresent)
|
if (ProxySwitch.IsPresent)
|
||||||
o.Add("proxy_switch", ProxySwitch.Value.ToUserString());
|
o.Add("proxy_switch", ProxySwitch.Value.ToUserString());
|
||||||
|
|
||||||
|
|
@ -150,6 +155,9 @@ public class SystemConfigPatch: PatchObject
|
||||||
if (o.ContainsKey("hid_display_caps"))
|
if (o.ContainsKey("hid_display_caps"))
|
||||||
patch.HidDisplayCaps = o.Value<bool>("hid_display_caps");
|
patch.HidDisplayCaps = o.Value<bool>("hid_display_caps");
|
||||||
|
|
||||||
|
if (o.ContainsKey("card_show_color_hex"))
|
||||||
|
patch.CardShowColorHex = o.Value<bool>("card_show_color_hex");
|
||||||
|
|
||||||
if (o.ContainsKey("proxy_switch"))
|
if (o.ContainsKey("proxy_switch"))
|
||||||
patch.ProxySwitch = o.Value<string>("proxy_switch") switch
|
patch.ProxySwitch = o.Value<string>("proxy_switch") switch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public class SystemConfig
|
||||||
public bool ProxyErrorMessageEnabled { get; }
|
public bool ProxyErrorMessageEnabled { get; }
|
||||||
public bool HidDisplaySplit { get; }
|
public bool HidDisplaySplit { get; }
|
||||||
public bool HidDisplayCaps { get; }
|
public bool HidDisplayCaps { get; }
|
||||||
|
public bool CardShowColorHex { get; }
|
||||||
public HidPadFormat HidListPadding { get; }
|
public HidPadFormat HidListPadding { get; }
|
||||||
public ProxySwitchAction ProxySwitch { get; }
|
public ProxySwitchAction ProxySwitch { get; }
|
||||||
public string NameFormat { get; }
|
public string NameFormat { get; }
|
||||||
|
|
@ -60,6 +61,7 @@ public static class SystemConfigExt
|
||||||
o.Add("hid_display_split", cfg.HidDisplaySplit);
|
o.Add("hid_display_split", cfg.HidDisplaySplit);
|
||||||
o.Add("hid_display_caps", cfg.HidDisplayCaps);
|
o.Add("hid_display_caps", cfg.HidDisplayCaps);
|
||||||
o.Add("hid_list_padding", cfg.HidListPadding.ToUserString());
|
o.Add("hid_list_padding", cfg.HidListPadding.ToUserString());
|
||||||
|
o.Add("card_show_color_hex", cfg.CardShowColorHex);
|
||||||
o.Add("proxy_switch", cfg.ProxySwitch.ToUserString());
|
o.Add("proxy_switch", cfg.ProxySwitch.ToUserString());
|
||||||
o.Add("name_format", cfg.NameFormat);
|
o.Add("name_format", cfg.NameFormat);
|
||||||
|
|
||||||
|
|
|
||||||
6
crates/migrate/data/migrations/53.sql
Normal file
6
crates/migrate/data/migrations/53.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- database version 53
|
||||||
|
-- add toggle for showing color codes on cv2 cards
|
||||||
|
|
||||||
|
alter table system_config add column card_show_color_hex bool default false;
|
||||||
|
|
||||||
|
update info set schema_version = 53;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue