Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ArchiSteamFarm/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -810,4 +810,16 @@ Process uptime: {1}</value>
<data name="WarningNoValidKeysFound" xml:space="preserve">
<value>No valid keys were found in your .keys file for redemption. Please ensure your keys are in the correct format.</value>
</data>
<data name="InfoKeysImported" xml:space="preserve">
<value>Successfully imported {0} key(s) from your .keys file.</value>
<comment>{0} will be replaced by number of imported keys (integer).</comment>
</data>
<data name="InfoKeysImportedSkipped" xml:space="preserve">
<value>Successfully imported {0} key(s) from your .keys file, {1} line(s) were skipped because they are not in the correct format, are comments or empty lines.</value>
<comment>{0} will be replaced by number of imported keys (integer), {1} will be replaced by number of skipped lines (integer).</comment>
</data>
<data name="InfoKeysLoaded" xml:space="preserve">
<value>Loaded {0} key(s) from queue.</value>
<comment>{0} will be replaced by number of keys (integer) in the queue.</comment>
</data>
</root>
10 changes: 10 additions & 0 deletions ArchiSteamFarm/Steam/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,12 @@ internal async Task ImportKeysToRedeem(string filePath) {
try {
OrderedDictionary<string, string> gamesToRedeemInBackground = new(StringComparer.OrdinalIgnoreCase);

int lineCount = 0;

using (StreamReader reader = new(filePath)) {
while (await reader.ReadLineAsync().ConfigureAwait(false) is { } line) {
lineCount++;

if (line.Length == 0) {
continue;
}
Expand Down Expand Up @@ -1504,8 +1508,12 @@ internal async Task ImportKeysToRedeem(string filePath) {
return;
}

int linesSkipped = lineCount - gamesToRedeemInBackground.Count;

AddGamesToRedeemInBackground(gamesToRedeemInBackground);

ArchiLogger.LogGenericInfo(linesSkipped > 0 ? Strings.FormatInfoKeysImportedSkipped(gamesToRedeemInBackground.Count, linesSkipped) : Strings.FormatInfoKeysImported(gamesToRedeemInBackground.Count));

File.Delete(filePath);
} catch (Exception e) {
ArchiLogger.LogGenericException(e);
Expand Down Expand Up @@ -3659,6 +3667,8 @@ private async void RedeemGamesInBackground(object? state = null) {

ArchiLogger.LogGenericInfo(Strings.Starting);

ArchiLogger.LogGenericInfo(Strings.FormatInfoKeysLoaded(GamesToRedeemInBackgroundCount));

bool assumeWalletKeyOnBadActivationCode = BotConfig.RedeemingPreferences.HasFlag(BotConfig.ERedeemingPreferences.AssumeWalletKeyOnBadActivationCode);

while (IsConnectedAndLoggedOn && BotDatabase.HasGamesToRedeemInBackground) {
Expand Down