mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Closes #583
This commit is contained in:
@@ -80,6 +80,7 @@ namespace ArchiSteamFarm {
|
|||||||
private readonly ConcurrentHashSet<ulong> HandledGifts = new ConcurrentHashSet<ulong>();
|
private readonly ConcurrentHashSet<ulong> HandledGifts = new ConcurrentHashSet<ulong>();
|
||||||
private readonly Timer HeartBeatTimer;
|
private readonly Timer HeartBeatTimer;
|
||||||
private readonly SemaphoreSlim InitializationSemaphore = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim InitializationSemaphore = new SemaphoreSlim(1);
|
||||||
|
private readonly SemaphoreSlim LootingSemaphore = new SemaphoreSlim(1);
|
||||||
private readonly ConcurrentHashSet<uint> OwnedPackageIDs = new ConcurrentHashSet<uint>();
|
private readonly ConcurrentHashSet<uint> OwnedPackageIDs = new ConcurrentHashSet<uint>();
|
||||||
|
|
||||||
private readonly Statistics Statistics;
|
private readonly Statistics Statistics;
|
||||||
@@ -2498,21 +2499,35 @@ namespace ArchiSteamFarm {
|
|||||||
return FormatBotResponse(Strings.BotLootingYourself);
|
return FormatBotResponse(Strings.BotLootingYourself);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<Steam.Item> inventory = await ArchiWebHandler.GetMySteamInventory(true, BotConfig.LootableTypes).ConfigureAwait(false);
|
if (!LootingSemaphore.Wait(0)) {
|
||||||
if ((inventory == null) || (inventory.Count == 0)) {
|
|
||||||
return FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(inventory)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!await ArchiWebHandler.MarkSentTrades().ConfigureAwait(false)) {
|
|
||||||
return FormatBotResponse(Strings.BotLootingFailed);
|
return FormatBotResponse(Strings.BotLootingFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await ArchiWebHandler.SendTradeOffer(inventory, targetSteamMasterID, BotConfig.SteamTradeToken).ConfigureAwait(false)) {
|
try {
|
||||||
return FormatBotResponse(Strings.BotLootingFailed);
|
HashSet<Steam.Item> inventory = await ArchiWebHandler.GetMySteamInventory(true, BotConfig.LootableTypes).ConfigureAwait(false);
|
||||||
|
if ((inventory == null) || (inventory.Count == 0)) {
|
||||||
|
return FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(inventory)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!await ArchiWebHandler.MarkSentTrades().ConfigureAwait(false)) {
|
||||||
|
return FormatBotResponse(Strings.BotLootingFailed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!await ArchiWebHandler.SendTradeOffer(inventory, targetSteamMasterID, BotConfig.SteamTradeToken).ConfigureAwait(false)) {
|
||||||
|
return FormatBotResponse(Strings.BotLootingFailed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HasMobileAuthenticator) {
|
||||||
|
// Give Steam network some time to generate confirmations
|
||||||
|
await Task.Delay(3000).ConfigureAwait(false);
|
||||||
|
if (!await AcceptConfirmations(true, Steam.ConfirmationDetails.EType.Trade, targetSteamMasterID).ConfigureAwait(false)) {
|
||||||
|
return FormatBotResponse(Strings.BotLootingFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
LootingSemaphore.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(3000).ConfigureAwait(false); // Sometimes we can be too fast for Steam servers to generate confirmations, wait a short moment
|
|
||||||
await AcceptConfirmations(true, Steam.ConfirmationDetails.EType.Trade, targetSteamMasterID).ConfigureAwait(false);
|
|
||||||
return FormatBotResponse(Strings.BotLootingSuccess);
|
return FormatBotResponse(Strings.BotLootingSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,8 +104,11 @@ namespace ArchiSteamFarm {
|
|||||||
if (Bot.HasMobileAuthenticator) {
|
if (Bot.HasMobileAuthenticator) {
|
||||||
HashSet<ulong> acceptedWithItemLoseTradeIDs = new HashSet<ulong>(results.Where(result => (result != null) && (result.Result == ParseTradeResult.EResult.AcceptedWithItemLose)).Select(result => result.TradeID));
|
HashSet<ulong> acceptedWithItemLoseTradeIDs = new HashSet<ulong>(results.Where(result => (result != null) && (result.Result == ParseTradeResult.EResult.AcceptedWithItemLose)).Select(result => result.TradeID));
|
||||||
if (acceptedWithItemLoseTradeIDs.Count > 0) {
|
if (acceptedWithItemLoseTradeIDs.Count > 0) {
|
||||||
await Task.Delay(3000).ConfigureAwait(false); // Sometimes we can be too fast for Steam servers to generate confirmations, wait a short moment
|
if (Bot.HasMobileAuthenticator) {
|
||||||
await Bot.AcceptConfirmations(true, Steam.ConfirmationDetails.EType.Trade, 0, acceptedWithItemLoseTradeIDs).ConfigureAwait(false);
|
// Give Steam network some time to generate confirmations
|
||||||
|
await Task.Delay(3000).ConfigureAwait(false);
|
||||||
|
await Bot.AcceptConfirmations(true, Steam.ConfirmationDetails.EType.Trade, 0, acceptedWithItemLoseTradeIDs).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user