mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(bot): config setting to pad 5-character ids in lists
This commit is contained in:
parent
0a6d4bcb76
commit
6d49961daf
7 changed files with 86 additions and 3 deletions
6
PluralKit.Core/Database/Migrations/43.sql
Normal file
6
PluralKit.Core/Database/Migrations/43.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- database version 43
|
||||
-- add config setting for padding 5-character IDs in lists
|
||||
|
||||
alter table system_config add column hid_list_padding int not null default 0;
|
||||
|
||||
update info set schema_version = 43;
|
||||
|
|
@ -9,7 +9,7 @@ namespace PluralKit.Core;
|
|||
internal class DatabaseMigrator
|
||||
{
|
||||
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
||||
private const int TargetSchemaVersion = 42;
|
||||
private const int TargetSchemaVersion = 43;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DatabaseMigrator(ILogger logger)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class SystemConfigPatch: PatchObject
|
|||
public Partial<bool> ProxyErrorMessageEnabled { get; set; }
|
||||
public Partial<bool> HidDisplaySplit { get; set; }
|
||||
public Partial<bool> HidDisplayCaps { get; set; }
|
||||
public Partial<SystemConfig.HidPadFormat> HidListPadding { get; set; }
|
||||
|
||||
|
||||
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
|
||||
|
|
@ -37,6 +38,7 @@ public class SystemConfigPatch: PatchObject
|
|||
.With("proxy_error_message_enabled", ProxyErrorMessageEnabled)
|
||||
.With("hid_display_split", HidDisplaySplit)
|
||||
.With("hid_display_caps", HidDisplayCaps)
|
||||
.With("hid_list_padding", HidListPadding)
|
||||
);
|
||||
|
||||
public new void AssertIsValid()
|
||||
|
|
@ -98,6 +100,9 @@ public class SystemConfigPatch: PatchObject
|
|||
if (HidDisplayCaps.IsPresent)
|
||||
o.Add("hid_display_caps", HidDisplayCaps.Value);
|
||||
|
||||
if (HidListPadding.IsPresent)
|
||||
o.Add("hid_list_padding", HidListPadding.Value.ToUserString());
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,14 @@ public class SystemConfig
|
|||
public bool ProxyErrorMessageEnabled { get; }
|
||||
public bool HidDisplaySplit { get; }
|
||||
public bool HidDisplayCaps { get; }
|
||||
public HidPadFormat HidListPadding { get; }
|
||||
|
||||
public enum HidPadFormat
|
||||
{
|
||||
None = 0,
|
||||
Left = 1,
|
||||
Right = 2,
|
||||
}
|
||||
}
|
||||
|
||||
public static class SystemConfigExt
|
||||
|
|
@ -43,9 +51,16 @@ public static class SystemConfigExt
|
|||
o.Add("proxy_error_message_enabled", cfg.ProxyErrorMessageEnabled);
|
||||
o.Add("hid_display_split", cfg.HidDisplaySplit);
|
||||
o.Add("hid_display_caps", cfg.HidDisplayCaps);
|
||||
o.Add("hid_list_padding", cfg.HidListPadding.ToUserString());
|
||||
|
||||
o.Add("description_templates", JArray.FromObject(cfg.DescriptionTemplates));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public static string ToUserString(this SystemConfig.HidPadFormat val)
|
||||
{
|
||||
if (val == SystemConfig.HidPadFormat.None) return "off";
|
||||
return val.ToString().ToLower();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue