Allow omitting the name in BGR import

Naming logic also applies to ASF API, but it's userspace in charge of making use of it.
This commit is contained in:
JustArchi
2018-11-28 23:36:56 +01:00
parent c4e6d34b85
commit b34039e10c

View File

@@ -678,8 +678,13 @@ namespace ArchiSteamFarm {
continue;
}
// Valid formats:
// Key (name will be the same as key and replaced from redemption result, if possible)
// Name + Key (user provides both, if name is equal to key, above logic is used, otherwise name is kept)
// Name + <Ignored> + Key (BGR output format, we include extra properties in the middle, those are ignored during import)
string[] parsedArgs = line.Split(DefaultBackgroundKeysRedeemerSeparator, StringSplitOptions.RemoveEmptyEntries);
if (parsedArgs.Length < 2) {
if (parsedArgs.Length < 1) {
ArchiLogger.LogGenericWarning(string.Format(Strings.ErrorIsInvalid, line));
continue;
}
@@ -2357,6 +2362,11 @@ namespace ArchiSteamFarm {
break;
}
// If user omitted the name or intentionally provided the same name as key, replace it with the Steam result
if (name.Equals(key) && (result.Items != null) && (result.Items.Count > 0)) {
name = string.Join(", ", result.Items.Values);
}
await BotDatabase.RemoveGameToRedeemInBackground(key).ConfigureAwait(false);
string logEntry = name + DefaultBackgroundKeysRedeemerSeparator + "[" + result.PurchaseResultDetail + "]" + ((result.Items != null) && (result.Items.Count > 0) ? DefaultBackgroundKeysRedeemerSeparator + string.Join(", ", result.Items) : "") + DefaultBackgroundKeysRedeemerSeparator + key;