diff --git a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs index fc77b616b..0a87ad431 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs @@ -283,7 +283,7 @@ public sealed class BotController : ArchiController { [HttpGet("{botNames:required}/Inventory/{appID}/{contextID}")] [ProducesResponseType>>((int) HttpStatusCode.OK)] [ProducesResponseType((int) HttpStatusCode.BadRequest)] - public async Task> InventoryGet(string botNames, uint appID, ulong contextID) { + public async Task> InventoryGet(string botNames, uint appID, ulong contextID, [FromQuery] string? language = null) { ArgumentException.ThrowIfNullOrEmpty(botNames); if (appID == 0) { @@ -300,7 +300,7 @@ public sealed class BotController : ArchiController { return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames))); } - IList<(HashSet? Result, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.GetInventory(appID, contextID))).ConfigureAwait(false); + IList<(HashSet? Result, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.GetInventory(appID, contextID, language: language))).ConfigureAwait(false); Dictionary result = new(bots.Count, Bot.BotsComparer); diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index ba6c50558..22977d006 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -179,7 +179,7 @@ public sealed class ArchiHandler : ClientMsgHandler, IDisposable { } [PublicAPI] - public async IAsyncEnumerable GetMyInventoryAsync(uint appID = Asset.SteamAppID, ulong contextID = Asset.SteamCommunityContextID, bool tradableOnly = false, bool marketableOnly = false, ushort itemsCountPerRequest = ArchiWebHandler.MaxItemsInSingleInventoryRequest) { + public async IAsyncEnumerable GetMyInventoryAsync(uint appID = Asset.SteamAppID, ulong contextID = Asset.SteamCommunityContextID, bool tradableOnly = false, bool marketableOnly = false, ushort itemsCountPerRequest = ArchiWebHandler.MaxItemsInSingleInventoryRequest, string? language = null) { ArgumentOutOfRangeException.ThrowIfZero(appID); ArgumentOutOfRangeException.ThrowIfZero(contextID); ArgumentOutOfRangeException.ThrowIfZero(itemsCountPerRequest); @@ -208,6 +208,10 @@ public sealed class ArchiHandler : ClientMsgHandler, IDisposable { count = itemsCountPerRequest }; + if (language != null) { + request.language = language; + } + // We need to store asset IDs to make sure we won't get duplicate items HashSet? assetIDs = null; diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index 3dff2dba4..d63a0c3f9 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -233,7 +233,7 @@ public sealed class ArchiWebHandler : IDisposable { /// This method should be used exclusively for foreign inventories (other users), but in special circumstances it can be used for fetching bot's own inventory as well. /// [PublicAPI] - public async IAsyncEnumerable GetInventoryAsync(ulong steamID = 0, uint appID = Asset.SteamAppID, ulong contextID = Asset.SteamCommunityContextID) { + public async IAsyncEnumerable GetInventoryAsync(ulong steamID = 0, uint appID = Asset.SteamAppID, ulong contextID = Asset.SteamCommunityContextID, string? language = null) { ArgumentOutOfRangeException.ThrowIfZero(appID); ArgumentOutOfRangeException.ThrowIfZero(contextID); @@ -259,6 +259,8 @@ public sealed class ArchiWebHandler : IDisposable { throw new InvalidOperationException(nameof(ASF.InventorySemaphore)); } + language ??= "english"; + ulong startAssetID = 0; // We need to store asset IDs to make sure we won't get duplicate items @@ -269,7 +271,7 @@ public sealed class ArchiWebHandler : IDisposable { int rateLimitingDelay = (ASF.GlobalConfig?.InventoryLimiterDelay ?? GlobalConfig.DefaultInventoryLimiterDelay) * 1000; while (true) { - Uri request = new(SteamCommunityURL, $"/inventory/{steamID}/{appID}/{contextID}?l=english&count={MaxItemsInSingleInventoryRequest}{(startAssetID > 0 ? $"&start_assetid={startAssetID}" : "")}"); + Uri request = new(SteamCommunityURL, $"/inventory/{steamID}/{appID}/{contextID}?l={language}&count={MaxItemsInSingleInventoryRequest}{(startAssetID > 0 ? $"&start_assetid={startAssetID}" : "")}"); await ASF.InventorySemaphore.WaitAsync().ConfigureAwait(false); diff --git a/ArchiSteamFarm/Steam/Interaction/Actions.cs b/ArchiSteamFarm/Steam/Interaction/Actions.cs index 75aaf72c8..b18d3d566 100644 --- a/ArchiSteamFarm/Steam/Interaction/Actions.cs +++ b/ArchiSteamFarm/Steam/Interaction/Actions.cs @@ -174,7 +174,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { /// This action should be used if you require full inventory exclusively, otherwise consider calling instead. [PublicAPI] - public async Task<(HashSet? Result, string Message)> GetInventory(uint appID = Asset.SteamAppID, ulong contextID = Asset.SteamCommunityContextID, Func? filterFunction = null) { + public async Task<(HashSet? Result, string Message)> GetInventory(uint appID = Asset.SteamAppID, ulong contextID = Asset.SteamCommunityContextID, Func? filterFunction = null, string? language = null) { ArgumentOutOfRangeException.ThrowIfZero(appID); ArgumentOutOfRangeException.ThrowIfZero(contextID); @@ -186,7 +186,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable { using (await GetTradingLock().ConfigureAwait(false)) { try { - return (await Bot.ArchiHandler.GetMyInventoryAsync(appID, contextID).Where(item => filterFunction(item)).ToHashSetAsync().ConfigureAwait(false), Strings.Success); + return (await Bot.ArchiHandler.GetMyInventoryAsync(appID, contextID, language: language).Where(item => filterFunction(item)).ToHashSetAsync().ConfigureAwait(false), Strings.Success); } catch (TimeoutException e) { Bot.ArchiLogger.LogGenericWarningException(e);