Add importing of Tupperbox multibrackets
This commit is contained in:
parent
9211ce0e7f
commit
1a79d52bfb
@ -64,15 +64,13 @@ namespace PluralKit.Bot.Commands
|
|||||||
if (!tupperbox.Valid) throw Errors.InvalidImportFile;
|
if (!tupperbox.Valid) throw Errors.InvalidImportFile;
|
||||||
|
|
||||||
var res = tupperbox.ToPluralKit();
|
var res = tupperbox.ToPluralKit();
|
||||||
if (res.HadGroups || res.HadMultibrackets || res.HadIndividualTags)
|
if (res.HadGroups || res.HadIndividualTags)
|
||||||
{
|
{
|
||||||
var issueStr =
|
var issueStr =
|
||||||
$"{Emojis.Warn} The following potential issues were detected converting your Tupperbox input file:";
|
$"{Emojis.Warn} The following potential issues were detected converting your Tupperbox input file:";
|
||||||
if (res.HadGroups)
|
if (res.HadGroups)
|
||||||
issueStr +=
|
issueStr +=
|
||||||
"\n- PluralKit does not support member groups. Members will be imported without groups.";
|
"\n- PluralKit does not support member groups. Members will be imported without groups.";
|
||||||
if (res.HadMultibrackets)
|
|
||||||
issueStr += "\n- PluralKit does not support members with multiple proxy tags. Only the first pair will be imported.";
|
|
||||||
if (res.HadIndividualTags)
|
if (res.HadIndividualTags)
|
||||||
issueStr +=
|
issueStr +=
|
||||||
"\n- PluralKit does not support per-member system tags. Since you had multiple members with distinct tags, tags will not be imported. You can set your system tag using the `pk;system tag <tag>` command later.";
|
"\n- PluralKit does not support per-member system tags. Since you had multiple members with distinct tags, tags will not be imported. You can set your system tag using the `pk;system tag <tag>` command later.";
|
||||||
|
@ -38,6 +38,7 @@ namespace PluralKit.Bot
|
|||||||
Color = m.Color,
|
Color = m.Color,
|
||||||
AvatarUrl = m.AvatarUrl,
|
AvatarUrl = m.AvatarUrl,
|
||||||
ProxyTags = m.ProxyTags,
|
ProxyTags = m.ProxyTags,
|
||||||
|
KeepProxy = m.KeepProxy,
|
||||||
Created = Formats.TimestampExportFormat.Format(m.Created),
|
Created = Formats.TimestampExportFormat.Format(m.Created),
|
||||||
MessageCount = messageCounts.Where(x => x.Member == m.Id).Select(x => x.MessageCount).FirstOrDefault()
|
MessageCount = messageCounts.Where(x => x.Member == m.Id).Select(x => x.MessageCount).FirstOrDefault()
|
||||||
}));
|
}));
|
||||||
@ -151,6 +152,12 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
member.ProxyTags = new List<ProxyTag> { new ProxyTag(dataMember.Prefix, dataMember.Suffix) };
|
member.ProxyTags = new List<ProxyTag> { new ProxyTag(dataMember.Prefix, dataMember.Suffix) };
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
member.ProxyTags = dataMember.ProxyTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
member.KeepProxy = dataMember.KeepProxy;
|
||||||
|
|
||||||
if (dataMember.Birthday != null)
|
if (dataMember.Birthday != null)
|
||||||
{
|
{
|
||||||
@ -229,6 +236,7 @@ namespace PluralKit.Bot
|
|||||||
// ^ is superseded by v
|
// ^ is superseded by v
|
||||||
[JsonProperty("proxy_tags")] public ICollection<ProxyTag> ProxyTags;
|
[JsonProperty("proxy_tags")] public ICollection<ProxyTag> ProxyTags;
|
||||||
|
|
||||||
|
[JsonProperty("keep_proxy")] public bool KeepProxy;
|
||||||
[JsonProperty("message_count")] public int MessageCount;
|
[JsonProperty("message_count")] public int MessageCount;
|
||||||
[JsonProperty("created")] public string Created;
|
[JsonProperty("created")] public string Created;
|
||||||
|
|
||||||
@ -245,7 +253,6 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
public bool HadGroups;
|
public bool HadGroups;
|
||||||
public bool HadIndividualTags;
|
public bool HadIndividualTags;
|
||||||
public bool HadMultibrackets;
|
|
||||||
public DataFileSystem System;
|
public DataFileSystem System;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,8 +272,8 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
output.System = new DataFileSystem
|
output.System = new DataFileSystem
|
||||||
{
|
{
|
||||||
Members = Tuppers.Select(t => t.ToPluralKit(ref lastSetTag, ref output.HadMultibrackets,
|
Members = Tuppers.Select(t => t.ToPluralKit(ref lastSetTag, ref output.HadIndividualTags,
|
||||||
ref output.HadGroups, ref output.HadMultibrackets)).ToList(),
|
ref output.HadGroups)).ToList(),
|
||||||
Switches = new List<DataFileSwitch>(),
|
Switches = new List<DataFileSwitch>(),
|
||||||
// If we haven't had multiple tags set, use the last (and only) one we set as the system tag
|
// If we haven't had multiple tags set, use the last (and only) one we set as the system tag
|
||||||
Tag = !output.HadIndividualTags ? lastSetTag : null
|
Tag = !output.HadIndividualTags ? lastSetTag : null
|
||||||
@ -279,9 +286,9 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
[JsonProperty("name")] public string Name;
|
[JsonProperty("name")] public string Name;
|
||||||
[JsonProperty("avatar_url")] public string AvatarUrl;
|
[JsonProperty("avatar_url")] public string AvatarUrl;
|
||||||
[JsonProperty("brackets")] public ICollection<string> Brackets;
|
[JsonProperty("brackets")] public IList<string> Brackets;
|
||||||
[JsonProperty("posts")] public int Posts; // Not supported by PK
|
[JsonProperty("posts")] public int Posts; // Not supported by PK
|
||||||
[JsonProperty("show_brackets")] public bool ShowBrackets; // Not supported by PK
|
[JsonProperty("show_brackets")] public bool ShowBrackets;
|
||||||
[JsonProperty("birthday")] public string Birthday;
|
[JsonProperty("birthday")] public string Birthday;
|
||||||
[JsonProperty("description")] public string Description;
|
[JsonProperty("description")] public string Description;
|
||||||
[JsonProperty("tag")] public string Tag; // Not supported by PK
|
[JsonProperty("tag")] public string Tag; // Not supported by PK
|
||||||
@ -290,7 +297,7 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
[JsonIgnore] public bool Valid => Name != null && Brackets != null && Brackets.Count % 2 == 0;
|
[JsonIgnore] public bool Valid => Name != null && Brackets != null && Brackets.Count % 2 == 0;
|
||||||
|
|
||||||
public DataFileMember ToPluralKit(ref string lastSetTag, ref bool multipleTags, ref bool hasGroup, ref bool hasMultiBrackets)
|
public DataFileMember ToPluralKit(ref string lastSetTag, ref bool multipleTags, ref bool hasGroup)
|
||||||
{
|
{
|
||||||
// If we've set a tag before and it's not the same as this one,
|
// If we've set a tag before and it's not the same as this one,
|
||||||
// then we have multiple unique tags and we pass that flag back to the caller
|
// then we have multiple unique tags and we pass that flag back to the caller
|
||||||
@ -302,8 +309,9 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
// Brackets in Tupperbox format are arranged as a single array
|
// Brackets in Tupperbox format are arranged as a single array
|
||||||
// [prefix1, suffix1, prefix2, suffix2, prefix3... etc]
|
// [prefix1, suffix1, prefix2, suffix2, prefix3... etc]
|
||||||
// If there are more than two entries this member has multiple brackets and we flag that
|
var tags = new List<ProxyTag>();
|
||||||
if (Brackets.Count > 2) hasMultiBrackets = true;
|
for (var i = 0; i < Brackets.Count / 2; i++)
|
||||||
|
tags.Add(new ProxyTag(Brackets[i * 2], Brackets[i * 2 + 1]));
|
||||||
|
|
||||||
return new DataFileMember
|
return new DataFileMember
|
||||||
{
|
{
|
||||||
@ -312,8 +320,8 @@ namespace PluralKit.Bot
|
|||||||
AvatarUrl = AvatarUrl,
|
AvatarUrl = AvatarUrl,
|
||||||
Birthday = Birthday,
|
Birthday = Birthday,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Prefix = Brackets.FirstOrDefault().NullIfEmpty(),
|
ProxyTags = tags,
|
||||||
Suffix = Brackets.Skip(1).FirstOrDefault().NullIfEmpty() // TODO: can Tupperbox members have no proxies at all?
|
KeepProxy = ShowBrackets
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user