Skip to content

Commit d68bb01

Browse files
committed
Add MaxTradeHoldDuration
1 parent da411b8 commit d68bb01

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

ArchiSteamFarm/GlobalConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ internal enum EUpdateChannel : byte {
8989
[JsonProperty(Required = Required.DisallowNull)]
9090
internal byte GiftsLimiterDelay { get; private set; } = 1;
9191

92+
[JsonProperty(Required = Required.DisallowNull)]
93+
internal byte MaxTradeHoldDuration { get; private set; } = 15;
94+
9295
[JsonProperty(Required = Required.DisallowNull)]
9396
internal bool ForceHttp { get; private set; } = false;
9497

ArchiSteamFarm/Trading.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,17 @@ private async Task<ParseTradeResult> ShouldAcceptTrade(Steam.TradeOffer tradeOff
185185

186186
// At this point we're sure that STM trade is valid
187187

188-
// If we're dealing with special cards with short lifespan, accept the trade only if user doesn't have trade holds
189-
if (tradeOffer.ItemsToGive.Any(item => GlobalConfig.GlobalBlacklist.Contains(item.RealAppID))) {
190-
byte? holdDuration = await Bot.ArchiWebHandler.GetTradeHoldDuration(tradeOffer.TradeOfferID).ConfigureAwait(false);
191-
if (!holdDuration.HasValue) {
192-
return ParseTradeResult.RejectedTemporarily;
193-
}
188+
// Fetch trade hold duration
189+
byte? holdDuration = await Bot.ArchiWebHandler.GetTradeHoldDuration(tradeOffer.TradeOfferID).ConfigureAwait(false);
190+
if (!holdDuration.HasValue) {
191+
// If we can't get trade hold duration, reject trade temporarily
192+
return ParseTradeResult.RejectedTemporarily;
193+
}
194194

195-
if (holdDuration.Value > 0) {
195+
// If user has a trade hold, we add extra logic
196+
if (holdDuration.Value > 0) {
197+
// If trade hold duration exceeds our max, or user asks for cards with short lifespan, reject the trade
198+
if ((holdDuration.Value > Program.GlobalConfig.MaxTradeHoldDuration) || tradeOffer.ItemsToGive.Any(item => GlobalConfig.GlobalBlacklist.Contains(item.RealAppID))) {
196199
return ParseTradeResult.RejectedPermanently;
197200
}
198201
}

ArchiSteamFarm/config/ASF.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"LoginLimiterDelay": 10,
1313
"InventoryLimiterDelay": 3,
1414
"GiftsLimiterDelay": 1,
15+
"MaxTradeHoldDuration": 15,
1516
"ForceHttp": false,
1617
"HttpTimeout": 60,
1718
"WCFHostname": "localhost",

ConfigGenerator/GlobalConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ internal enum EUpdateChannel : byte {
8989
[JsonProperty(Required = Required.DisallowNull)]
9090
public byte GiftsLimiterDelay { get; set; } = 1;
9191

92+
[JsonProperty(Required = Required.DisallowNull)]
93+
public byte MaxTradeHoldDuration { get; set; } = 15;
94+
9295
[JsonProperty(Required = Required.DisallowNull)]
9396
public bool ForceHttp { get; set; } = false;
9497

0 commit comments

Comments
 (0)