Skip to content

Commit

Permalink
Revert back to using AWH for inventory fetching
Browse files Browse the repository at this point in the history
New method randomly returns an empty inventory which is something the old method never did
  • Loading branch information
Citrinate committed Mar 24, 2024
1 parent 344a22e commit d68141d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions BoosterManager/Handlers/GemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class GemHandler {
internal static async Task<string> GetGemCount(Bot bot) {
HashSet<Asset> inventory;
try {
inventory = await bot.ArchiHandler.GetMyInventoryAsync().Where(item => ItemIdentifier.GemAndSackIdentifier.IsItemMatch(item)).ToHashSetAsync().ConfigureAwait(false);
inventory = await bot.ArchiWebHandler.GetInventoryAsync().Where(item => ItemIdentifier.GemAndSackIdentifier.IsItemMatch(item)).ToHashSetAsync().ConfigureAwait(false);
} catch (Exception e) {
bot.ArchiLogger.LogGenericException(e);
return Commands.FormatBotResponse(bot, ArchiSteamFarm.Localization.Strings.WarningFailed);
Expand Down Expand Up @@ -53,7 +53,7 @@ internal static async Task<string> GetGemCount(Bot bot) {
internal static async Task<string> UnpackGems(Bot bot) {
HashSet<Asset> sacks;
try {
sacks = await bot.ArchiHandler.GetMyInventoryAsync().Where(item => ItemIdentifier.SackIdentifier.IsItemMatch(item) && (BoosterHandler.AllowCraftUntradableBoosters || item.Tradable)).ToHashSetAsync().ConfigureAwait(false);
sacks = await bot.ArchiWebHandler.GetInventoryAsync().Where(item => ItemIdentifier.SackIdentifier.IsItemMatch(item) && (BoosterHandler.AllowCraftUntradableBoosters || item.Tradable)).ToHashSetAsync().ConfigureAwait(false);
} catch (Exception e) {
bot.ArchiLogger.LogGenericException(e);
return Commands.FormatBotResponse(bot, ArchiSteamFarm.Localization.Strings.WarningFailed);
Expand Down
4 changes: 2 additions & 2 deletions BoosterManager/Handlers/InventoryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static async Task<string> SendItemToMultipleBots(Bot sender, List<(Bot

HashSet<Asset> itemStacks;
try {
itemStacks = await sender.ArchiHandler.GetMyInventoryAsync(appID: appID, contextID: contextID).Where(item => item.Tradable && itemIdentifier.IsItemMatch(item)).ToHashSetAsync().ConfigureAwait(false);
itemStacks = await sender.ArchiWebHandler.GetInventoryAsync(appID: appID, contextID: contextID).Where(item => item.Tradable && itemIdentifier.IsItemMatch(item)).ToHashSetAsync().ConfigureAwait(false);
} catch (Exception e) {
sender.ArchiLogger.LogGenericException(e);
return Commands.FormatBotResponse(sender, ArchiSteamFarm.Localization.Strings.WarningFailed);
Expand Down Expand Up @@ -80,7 +80,7 @@ internal static async Task<string> SendMultipleItemsToMultipleBots(Bot sender, H

HashSet<Asset> inventory;
try {
inventory = await sender.ArchiHandler.GetMyInventoryAsync(appID: appID, contextID: contextID).ToHashSetAsync().ConfigureAwait(false);
inventory = await sender.ArchiWebHandler.GetInventoryAsync(appID: appID, contextID: contextID).ToHashSetAsync().ConfigureAwait(false);
} catch (Exception e) {
sender.ArchiLogger.LogGenericException(e);
return Commands.FormatBotResponse(sender, ArchiSteamFarm.Localization.Strings.WarningFailed);
Expand Down
2 changes: 1 addition & 1 deletion BoosterManager/Handlers/KeyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class KeyHandler {
internal static async Task<string> GetKeyCount(Bot bot) {
HashSet<Asset> inventory;
try {
inventory = await bot.ArchiHandler.GetMyInventoryAsync(appID: KeyAppID, contextID: KeyContextID).Where(item => ItemIdentifier.KeyIdentifier.IsItemMatch(item)).ToHashSetAsync().ConfigureAwait(false);
inventory = await bot.ArchiWebHandler.GetInventoryAsync(appID: KeyAppID, contextID: KeyContextID).Where(item => ItemIdentifier.KeyIdentifier.IsItemMatch(item)).ToHashSetAsync().ConfigureAwait(false);
} catch (Exception e) {
bot.ArchiLogger.LogGenericException(e);
return Commands.FormatBotResponse(bot, ArchiSteamFarm.Localization.Strings.WarningFailed);
Expand Down

3 comments on commit d68141d

@JustArchi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in latest pre-release 🙂

@Citrinate
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JustArchi Note that this isn't the same as JustArchiNET/ArchiSteamFarm#3171, which I saw was addressed in V6.0.1.13.

My problem still exists in V6.0.1.13 and I don't see any changes related to GetMyInventoryAsync in newer versions.

My experience is that loading an inventory using GetMyInventoryAsync will usually correctly return the inventory, but then randomly it returns nothing. When nothing is returned, ASF logs no errors. When trying to load the inventories of 5 bots at the same time, they either all succeed or they all fail (inventory sizes here are all less than 1000 items). These are my experiences from using ASF as I normally do and without any further testing. I figure it's just an annoying quirk of the new API being used.

@JustArchi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we need some internal retry or more info regarding those failures, I haven't seen them before.

@Citrinate I've added additional details in 6.0.1.17, if you can reproduce and report the exact exception you've got then perhaps I can add some retry there and fetch the inventory just right - please report through discord or GitHub with full log, thanks in advance 🙂.

JustArchiNET/ArchiSteamFarm@4cb3eab

Please sign in to comment.