mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-26 19:26:48 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef5b108b34 | ||
|
|
1ee9fec845 | ||
|
|
4bf1462381 | ||
|
|
e41d2cf37e | ||
|
|
fac5e65035 | ||
|
|
b44115711b |
@@ -253,41 +253,45 @@ namespace ArchiSteamFarm {
|
||||
Trading?.Dispose();
|
||||
}
|
||||
|
||||
internal async Task AcceptConfirmations(bool accept, Steam.ConfirmationDetails.EType acceptedType = Steam.ConfirmationDetails.EType.Unknown, ulong acceptedSteamID = 0, HashSet<ulong> acceptedTradeIDs = null) {
|
||||
internal async Task<bool> AcceptConfirmations(bool accept, Steam.ConfirmationDetails.EType acceptedType = Steam.ConfirmationDetails.EType.Unknown, ulong acceptedSteamID = 0, HashSet<ulong> acceptedTradeIDs = null) {
|
||||
if (BotDatabase.MobileAuthenticator == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
HashSet<MobileAuthenticator.Confirmation> confirmations = await BotDatabase.MobileAuthenticator.GetConfirmations().ConfigureAwait(false);
|
||||
if ((confirmations == null) || (confirmations.Count == 0)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (acceptedType != Steam.ConfirmationDetails.EType.Unknown) {
|
||||
if (confirmations.RemoveWhere(confirmation => (confirmation.Type != acceptedType) && (confirmation.Type != Steam.ConfirmationDetails.EType.Other)) > 0) {
|
||||
if (confirmations.Count == 0) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((acceptedSteamID != 0) || ((acceptedTradeIDs != null) && (acceptedTradeIDs.Count > 0))) {
|
||||
Steam.ConfirmationDetails[] detailsResults = await Task.WhenAll(confirmations.Select(BotDatabase.MobileAuthenticator.GetConfirmationDetails)).ConfigureAwait(false);
|
||||
|
||||
HashSet<MobileAuthenticator.Confirmation> ignoredConfirmations = new HashSet<MobileAuthenticator.Confirmation>(detailsResults.Where(details => (details != null) && (
|
||||
((acceptedSteamID != 0) && (details.OtherSteamID64 != 0) && (acceptedSteamID != details.OtherSteamID64)) ||
|
||||
((acceptedTradeIDs != null) && (details.TradeOfferID != 0) && !acceptedTradeIDs.Contains(details.TradeOfferID))
|
||||
)).Select(details => details.Confirmation));
|
||||
|
||||
if (ignoredConfirmations.Count > 0) {
|
||||
confirmations.ExceptWith(ignoredConfirmations);
|
||||
if (confirmations.Count == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((acceptedSteamID == 0) && ((acceptedTradeIDs == null) || (acceptedTradeIDs.Count == 0))) {
|
||||
return await BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false);
|
||||
Steam.ConfirmationDetails[] detailsResults = await Task.WhenAll(confirmations.Select(BotDatabase.MobileAuthenticator.GetConfirmationDetails)).ConfigureAwait(false);
|
||||
|
||||
HashSet<MobileAuthenticator.Confirmation> ignoredConfirmations = new HashSet<MobileAuthenticator.Confirmation>(detailsResults.Where(details => (details != null) && (
|
||||
((acceptedSteamID != 0) && (details.OtherSteamID64 != 0) && (acceptedSteamID != details.OtherSteamID64)) ||
|
||||
((acceptedTradeIDs != null) && (details.TradeOfferID != 0) && !acceptedTradeIDs.Contains(details.TradeOfferID))
|
||||
)).Select(details => details.Confirmation));
|
||||
|
||||
if (ignoredConfirmations.Count == 0) {
|
||||
return await BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
confirmations.ExceptWith(ignoredConfirmations);
|
||||
if (confirmations.Count == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return await BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal async Task<bool> RefreshSession() {
|
||||
@@ -800,8 +804,11 @@ namespace ArchiSteamFarm {
|
||||
return "That bot doesn't have ASF 2FA enabled!";
|
||||
}
|
||||
|
||||
await AcceptConfirmations(confirm).ConfigureAwait(false);
|
||||
return "Done!";
|
||||
if (await AcceptConfirmations(confirm).ConfigureAwait(false)) {
|
||||
return "Success!";
|
||||
}
|
||||
|
||||
return "Something went wrong!";
|
||||
}
|
||||
|
||||
private static async Task<string> Response2FAConfirm(ulong steamID, string botName, bool confirm) {
|
||||
@@ -973,7 +980,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
bool alreadyHandled = false;
|
||||
foreach (Bot bot in Bots.Values.Where(bot => (bot != this) && bot.SteamClient.IsConnected && result.Items.Keys.Any(packageID => !bot.OwnedPackageIDs.Contains(packageID)))) {
|
||||
foreach (Bot bot in Bots.Values.Where(bot => (bot != this) && bot.SteamClient.IsConnected && ((result.Items.Count == 0) || result.Items.Keys.Any(packageID => !bot.OwnedPackageIDs.Contains(packageID))))) {
|
||||
|
||||
ArchiHandler.PurchaseResponseCallback otherResult = await bot.ArchiHandler.RedeemKey(key).ConfigureAwait(false);
|
||||
if (otherResult == null) {
|
||||
@@ -994,6 +1001,14 @@ namespace ArchiSteamFarm {
|
||||
if (alreadyHandled) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.Items.Count != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<uint, string> item in otherResult.Items) {
|
||||
result.Items[item.Key] = item.Value;
|
||||
}
|
||||
}
|
||||
|
||||
key = reader.ReadLine(); // Next key
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -55,6 +56,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
private const byte CodeDigits = 5;
|
||||
private const byte CodeInterval = 30;
|
||||
private const byte MaxConfirmationsPerRequest = 5; // This is limit enforced by Valve - using higher number might result in likeness of requests failing
|
||||
|
||||
private static readonly char[] CodeCharacters = {
|
||||
'2', '3', '4', '5', '6', '7', '8', '9', 'B', 'C',
|
||||
@@ -115,12 +117,28 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
string confirmationHash = GenerateConfirmationKey(time, "conf");
|
||||
if (!string.IsNullOrEmpty(confirmationHash)) {
|
||||
if (string.IsNullOrEmpty(confirmationHash)) {
|
||||
Logging.LogNullError(nameof(confirmationHash), Bot.BotName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (confirmations.Count <= MaxConfirmationsPerRequest) {
|
||||
return await Bot.ArchiWebHandler.HandleConfirmations(DeviceID, confirmationHash, time, confirmations, accept).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Logging.LogNullError(nameof(confirmationHash), Bot.BotName);
|
||||
return false;
|
||||
HashSet<Confirmation> pendingConfirmations = new HashSet<Confirmation>(confirmations);
|
||||
|
||||
do {
|
||||
HashSet<Confirmation> currentConfirmations = new HashSet<Confirmation>(pendingConfirmations.Take(MaxConfirmationsPerRequest));
|
||||
|
||||
if (!await Bot.ArchiWebHandler.HandleConfirmations(DeviceID, confirmationHash, time, currentConfirmations, accept).ConfigureAwait(false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pendingConfirmations.ExceptWith(currentConfirmations);
|
||||
} while (pendingConfirmations.Count > 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal async Task<Steam.ConfirmationDetails> GetConfirmationDetails(Confirmation confirmation) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class SharedInfo {
|
||||
internal const string Version = "2.1.3.2";
|
||||
internal const string Version = "2.1.3.4";
|
||||
internal const string Copyright = "Copyright © ArchiSteamFarm 2015-2016";
|
||||
|
||||
internal const string GithubRepo = "JustArchi/ArchiSteamFarm";
|
||||
|
||||
Reference in New Issue
Block a user