From 6b4ae6a4d7ecb2b9d69de96959b39e45ccb22224 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Fri, 24 Jun 2016 20:27:23 +0200 Subject: [PATCH] Do not attempt to handle the same gift more than one time --- ArchiSteamFarm/Bot.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 675a398a4..e0b9f2e52 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -60,6 +60,7 @@ namespace ArchiSteamFarm { [JsonProperty] private readonly CardsFarmer CardsFarmer; + private readonly ConcurrentHashSet HandledGifts = new ConcurrentHashSet(); private readonly SteamApps SteamApps; private readonly SteamFriends SteamFriends; private readonly SteamUser SteamUser; @@ -1517,6 +1518,7 @@ namespace ArchiSteamFarm { FirstTradeSent = false; CardsFarmer.StopFarming().Forget(); + HandledGifts.ClearAndTrim(); // If we initiated disconnect, do not attempt to reconnect if (callback.UserInitiated) { @@ -1573,10 +1575,11 @@ namespace ArchiSteamFarm { } bool acceptedSomething = false; - foreach (ulong gid in callback.GuestPasses.Select(guestPass => guestPass["gid"].AsUnsignedLong()).Where(gid => gid != 0)) { + foreach (ulong gid in callback.GuestPasses.Select(guestPass => guestPass["gid"].AsUnsignedLong()).Where(gid => (gid != 0) && !HandledGifts.Contains(gid))) { Logging.LogGenericInfo("Accepting gift: " + gid + "...", BotName); if (await ArchiWebHandler.AcceptGift(gid).ConfigureAwait(false)) { acceptedSomething = true; + HandledGifts.Add(gid); Logging.LogGenericInfo("Success!", BotName); } else { Logging.LogGenericInfo("Failed!", BotName);