Skip to content

Commit 1eadaad

Browse files
committed
Fix rp command not working with badge upgrades
Of course volvo had to use different endpoint for that, it'd be too easy otherwise
1 parent 22e424a commit 1eadaad

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

ArchiSteamFarm/Steam/Integration/ArchiHandler.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,36 @@ public async Task<EResult> RedeemPoints(uint definitionID) {
628628
return response.Result;
629629
}
630630

631+
[PublicAPI]
632+
public async Task<EResult> RedeemPointsForBadgeLevel(uint definitionID, byte levels = 1) {
633+
ArgumentOutOfRangeException.ThrowIfZero(definitionID);
634+
635+
if (Client == null) {
636+
throw new InvalidOperationException(nameof(Client));
637+
}
638+
639+
if (!Client.IsConnected) {
640+
return EResult.NoConnection;
641+
}
642+
643+
CLoyaltyRewards_RedeemPointsForBadgeLevel_Request request = new() {
644+
defid = definitionID,
645+
num_levels = levels
646+
};
647+
648+
SteamUnifiedMessages.ServiceMethodResponse<CLoyaltyRewards_RedeemPoints_Response> response;
649+
650+
try {
651+
response = await UnifiedLoyaltyRewards.RedeemPointsForBadgeLevel(request).ToLongRunningTask().ConfigureAwait(false);
652+
} catch (Exception e) {
653+
ArchiLogger.LogGenericWarningException(e);
654+
655+
return EResult.Timeout;
656+
}
657+
658+
return response.Result;
659+
}
660+
631661
[PublicAPI]
632662
public async Task<bool> RemoveFriend(ulong steamID) {
633663
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {

ArchiSteamFarm/Steam/Interaction/Actions.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,23 +354,23 @@ public static string Hash(ArchiCryptoHelper.EHashingMethod hashingMethod, string
354354
public async Task<EResult> RedeemPoints(uint definitionID, bool forced = false) {
355355
ArgumentOutOfRangeException.ThrowIfZero(definitionID);
356356

357-
if (!forced) {
358-
Dictionary<uint, LoyaltyRewardDefinition>? definitions = await Bot.Actions.GetRewardItems(new HashSet<uint>(1) { definitionID }).ConfigureAwait(false);
357+
Dictionary<uint, LoyaltyRewardDefinition>? definitions = await Bot.Actions.GetRewardItems(new HashSet<uint>(1) { definitionID }).ConfigureAwait(false);
359358

360-
if (definitions == null) {
361-
return EResult.Timeout;
362-
}
359+
if (definitions == null) {
360+
return EResult.Timeout;
361+
}
363362

364-
if (!definitions.TryGetValue(definitionID, out LoyaltyRewardDefinition? definition)) {
365-
return EResult.InvalidParam;
366-
}
363+
if (!definitions.TryGetValue(definitionID, out LoyaltyRewardDefinition? definition)) {
364+
return EResult.InvalidParam;
365+
}
367366

367+
if (!forced) {
368368
if (definition.point_cost > 0) {
369369
return EResult.InvalidState;
370370
}
371371
}
372372

373-
return await Bot.ArchiHandler.RedeemPoints(definitionID).ConfigureAwait(false);
373+
return definition.type == 2 ? await Bot.ArchiHandler.RedeemPointsForBadgeLevel(definitionID).ConfigureAwait(false) : await Bot.ArchiHandler.RedeemPoints(definitionID).ConfigureAwait(false);
374374
}
375375

376376
[PublicAPI]

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>6.2.2.0</Version>
3+
<Version>6.2.2.1</Version>
44
</PropertyGroup>
55

66
<PropertyGroup>

0 commit comments

Comments
 (0)