From 1eadaad9bdfe1cd73d3fdebef7a1dcf89403e2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Mon, 8 Sep 2025 02:41:31 +0200 Subject: [PATCH] Fix rp command not working with badge upgrades Of course volvo had to use different endpoint for that, it'd be too easy otherwise --- .../Steam/Integration/ArchiHandler.cs | 30 +++++++++++++++++++ ArchiSteamFarm/Steam/Interaction/Actions.cs | 22 +++++++------- Directory.Build.props | 2 +- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index 57425dd20..61f978e1e 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -628,6 +628,36 @@ public sealed class ArchiHandler : ClientMsgHandler, IDisposable { return response.Result; } + [PublicAPI] + public async Task RedeemPointsForBadgeLevel(uint definitionID, byte levels = 1) { + ArgumentOutOfRangeException.ThrowIfZero(definitionID); + + if (Client == null) { + throw new InvalidOperationException(nameof(Client)); + } + + if (!Client.IsConnected) { + return EResult.NoConnection; + } + + CLoyaltyRewards_RedeemPointsForBadgeLevel_Request request = new() { + defid = definitionID, + num_levels = levels + }; + + SteamUnifiedMessages.ServiceMethodResponse response; + + try { + response = await UnifiedLoyaltyRewards.RedeemPointsForBadgeLevel(request).ToLongRunningTask().ConfigureAwait(false); + } catch (Exception e) { + ArchiLogger.LogGenericWarningException(e); + + return EResult.Timeout; + } + + return response.Result; + } + [PublicAPI] public async Task RemoveFriend(ulong steamID) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) { diff --git a/ArchiSteamFarm/Steam/Interaction/Actions.cs b/ArchiSteamFarm/Steam/Interaction/Actions.cs index bac619575..7bd09d04e 100644 --- a/ArchiSteamFarm/Steam/Interaction/Actions.cs +++ b/ArchiSteamFarm/Steam/Interaction/Actions.cs @@ -354,23 +354,23 @@ public sealed class Actions : IAsyncDisposable, IDisposable { public async Task RedeemPoints(uint definitionID, bool forced = false) { ArgumentOutOfRangeException.ThrowIfZero(definitionID); + Dictionary? definitions = await Bot.Actions.GetRewardItems(new HashSet(1) { definitionID }).ConfigureAwait(false); + + if (definitions == null) { + return EResult.Timeout; + } + + if (!definitions.TryGetValue(definitionID, out LoyaltyRewardDefinition? definition)) { + return EResult.InvalidParam; + } + if (!forced) { - Dictionary? definitions = await Bot.Actions.GetRewardItems(new HashSet(1) { definitionID }).ConfigureAwait(false); - - if (definitions == null) { - return EResult.Timeout; - } - - if (!definitions.TryGetValue(definitionID, out LoyaltyRewardDefinition? definition)) { - return EResult.InvalidParam; - } - if (definition.point_cost > 0) { return EResult.InvalidState; } } - return await Bot.ArchiHandler.RedeemPoints(definitionID).ConfigureAwait(false); + return definition.type == 2 ? await Bot.ArchiHandler.RedeemPointsForBadgeLevel(definitionID).ConfigureAwait(false) : await Bot.ArchiHandler.RedeemPoints(definitionID).ConfigureAwait(false); } [PublicAPI] diff --git a/Directory.Build.props b/Directory.Build.props index 57c2253bd..c76bd9dcd 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 6.2.2.0 + 6.2.2.1