Skip to content

Commit

Permalink
Fix broken transfer commands when bots aren't friends
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Jan 26, 2025
1 parent bd9a737 commit fc70b70
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions BoosterManager/Handlers/InventoryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Steam.Data;
using BoosterManager.Localization;
using SteamKit2;

namespace BoosterManager {
internal static class InventoryHandler {
Expand Down Expand Up @@ -56,13 +57,18 @@ internal static async Task<string> SendItemToMultipleBots(Bot sender, List<(Bot
if (amountToSend == 0) {
return (true, Strings.SendingNoItems);
}

string? tradeToken = null;
if (sender.SteamFriends.GetFriendRelationship(reciever.SteamID) != EFriendRelationship.Friend) {
tradeToken = await reciever.ArchiHandler.GetTradeToken().ConfigureAwait(false);
}

HashSet<Asset>? itemsToGive = GetItemsFromStacks(sender, itemStacks, amountToSend, amountToSkip);
if (itemsToGive == null) {
return (false, Strings.SendingInsufficientQuantity);
}

(bool success, _, HashSet<ulong>? mobileTradeOfferIDs) = await sender.ArchiWebHandler.SendTradeOffer(reciever.SteamID, itemsToGive).ConfigureAwait(false);
(bool success, _, HashSet<ulong>? mobileTradeOfferIDs) = await sender.ArchiWebHandler.SendTradeOffer(reciever.SteamID, itemsToGive, token: tradeToken).ConfigureAwait(false);
if ((mobileTradeOfferIDs?.Count > 0) && sender.HasMobileAuthenticator) {
(bool twoFactorSuccess, _, string message) = await sender.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);

Expand Down Expand Up @@ -129,6 +135,11 @@ internal static async Task<string> SendMultipleItemsToMultipleBots(Bot sender, H
return (false, ArchiSteamFarm.Localization.Strings.BotSendingTradeToYourself);
}

string? tradeToken = null;
if (sender.SteamFriends.GetFriendRelationship(reciever.SteamID) != EFriendRelationship.Friend) {
tradeToken = await reciever.ArchiHandler.GetTradeToken().ConfigureAwait(false);
}

HashSet<Asset> totalItemsToGive = new HashSet<Asset>();
HashSet<string> responses = new HashSet<string>();
bool completeSuccess = true;
Expand All @@ -152,7 +163,7 @@ internal static async Task<string> SendMultipleItemsToMultipleBots(Bot sender, H
return (false, String.Join(Environment.NewLine, responses));
}

(bool success, _, HashSet<ulong>? mobileTradeOfferIDs) = await sender.ArchiWebHandler.SendTradeOffer(reciever.SteamID, totalItemsToGive).ConfigureAwait(false);
(bool success, _, HashSet<ulong>? mobileTradeOfferIDs) = await sender.ArchiWebHandler.SendTradeOffer(reciever.SteamID, totalItemsToGive, token: tradeToken).ConfigureAwait(false);
if ((mobileTradeOfferIDs?.Count > 0) && sender.HasMobileAuthenticator) {
(bool twoFactorSuccess, _, string message) = await sender.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);

Expand Down

0 comments on commit fc70b70

Please sign in to comment.