Open TradingLock and API key check for public

This commit is contained in:
JustArchi
2019-08-16 16:37:55 +02:00
parent c95924d7d6
commit ca2109d3d7
2 changed files with 15 additions and 13 deletions

View File

@@ -79,6 +79,14 @@ namespace ArchiSteamFarm {
return (true, token, Strings.Success);
}
[ItemNotNull]
[PublicAPI]
public async Task<IDisposable> GetTradingLock() {
await TradingSemaphore.WaitAsync().ConfigureAwait(false);
return new SemaphoreLock(TradingSemaphore);
}
[PublicAPI]
public async Task<(bool Success, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, Steam.ConfirmationDetails.EType? acceptedType = null, IReadOnlyCollection<ulong> acceptedTradeOfferIDs = null, bool waitIfNeeded = false) {
if (!Bot.HasMobileAuthenticator) {
@@ -413,13 +421,6 @@ namespace ArchiSteamFarm {
}
}
[ItemNotNull]
internal async Task<SemaphoreLock> GetTradingLock() {
await TradingSemaphore.WaitAsync().ConfigureAwait(false);
return new SemaphoreLock(TradingSemaphore);
}
internal void OnDisconnected() => HandledGifts.Clear();
private ulong GetFirstSteamMasterID() => Bot.BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderByDescending(steamID => steamID != Bot.SteamID).ThenBy(steamID => steamID).FirstOrDefault();

View File

@@ -354,6 +354,13 @@ namespace ArchiSteamFarm {
return result;
}
[PublicAPI]
public async Task<bool?> HasValidApiKey() {
(bool success, string steamApiKey) = await CachedApiKey.GetValue().ConfigureAwait(false);
return success ? !string.IsNullOrEmpty(steamApiKey) : (bool?) null;
}
[PublicAPI]
public async Task<(bool Success, HashSet<ulong> MobileTradeOfferIDs)> SendTradeOffer(ulong steamID, IReadOnlyCollection<Steam.Asset> itemsToGive = null, IReadOnlyCollection<Steam.Asset> itemsToReceive = null, string token = null, bool forcedSingleOffer = false) {
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || (((itemsToGive == null) || (itemsToGive.Count == 0)) && ((itemsToReceive == null) || (itemsToReceive.Count == 0)))) {
@@ -2000,12 +2007,6 @@ namespace ArchiSteamFarm {
return success ? hasPublicInventory : (bool?) null;
}
internal async Task<bool?> HasValidApiKey() {
(bool success, string steamApiKey) = await CachedApiKey.GetValue().ConfigureAwait(false);
return success ? !string.IsNullOrEmpty(steamApiKey) : (bool?) null;
}
internal async Task<bool> Init(ulong steamID, EUniverse universe, string webAPIUserNonce, string parentalCode = null) {
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || (universe == EUniverse.Invalid) || !Enum.IsDefined(typeof(EUniverse), universe) || string.IsNullOrEmpty(webAPIUserNonce)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(universe) + " || " + nameof(webAPIUserNonce));