mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Post-cleanup after #2330
This commit is contained in:
6
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
6
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
@@ -538,14 +538,14 @@ namespace ArchiSteamFarm.Localization {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Points balance:{0}..
|
||||
/// Looks up a localized string similar to Points balance:{0}.
|
||||
/// </summary>
|
||||
public static string BotPointsBalance {
|
||||
get {
|
||||
return ResourceManager.GetString("BotPointsBalance", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Rate limit exceeded, we will retry after {0} of cooldown....
|
||||
/// </summary>
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
// _ _ _ ____ _ _____
|
||||
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
||||
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
||||
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
||||
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
||||
// |
|
||||
// Copyright 2015-2021 Łukasz "JustArchi" Domeradzki
|
||||
// Contact: JustArchi@JustArchi.net
|
||||
// |
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// |
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// |
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
@@ -6,12 +26,18 @@ namespace ArchiSteamFarm.Steam.Data {
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
internal sealed class AccessTokenResponse : EResultResponse {
|
||||
[JsonProperty(PropertyName = "data", Required = Required.Always)]
|
||||
internal AccessTokenData AccessTokenData { get; private set; } = new();
|
||||
}
|
||||
internal readonly AccessTokenData Data = new();
|
||||
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
internal sealed class AccessTokenData {
|
||||
[JsonProperty(PropertyName = "webapi_token", Required = Required.Always)]
|
||||
internal string WebAPIToken { get; private set; } = "";
|
||||
[JsonConstructor]
|
||||
private AccessTokenResponse() { }
|
||||
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
internal sealed class AccessTokenData {
|
||||
[JsonProperty(PropertyName = "webapi_token", Required = Required.Always)]
|
||||
internal readonly string WebAPIToken = "";
|
||||
|
||||
[JsonConstructor]
|
||||
internal AccessTokenData() { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ using SteamKit2;
|
||||
namespace ArchiSteamFarm.Steam.Data {
|
||||
[PublicAPI]
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class EResultResponse {
|
||||
[JsonProperty(PropertyName = "success", Required = Required.Always)]
|
||||
public EResult Result { get; private set; }
|
||||
|
||||
@@ -57,11 +57,11 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
internal const ushort MaxItemsInSingleInventoryRequest = 5000;
|
||||
|
||||
private const string EconService = "IEconService";
|
||||
private const string LoyaltyRewardsService = "ILoyaltyRewardsService";
|
||||
private const string PlayerService = "IPlayerService";
|
||||
private const string SteamAppsService = "ISteamApps";
|
||||
private const string SteamUserAuthService = "ISteamUserAuth";
|
||||
private const string TwoFactorService = "ITwoFactorService";
|
||||
private const string LoyaltyRewardsService = "ILoyaltyRewardsService";
|
||||
|
||||
[PublicAPI]
|
||||
public static Uri SteamCommunityURL => new("https://steamcommunity.com");
|
||||
@@ -74,11 +74,12 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
|
||||
private static readonly ConcurrentDictionary<uint, byte> CachedCardCountsForGame = new();
|
||||
|
||||
[PublicAPI]
|
||||
public ArchiCacheable<string> CachedApiKey { get; }
|
||||
[PublicAPI]
|
||||
public ArchiCacheable<string> CachedAccessToken { get; }
|
||||
|
||||
[PublicAPI]
|
||||
public ArchiCacheable<string> CachedApiKey { get; }
|
||||
|
||||
[PublicAPI]
|
||||
public WebBrowser WebBrowser { get; }
|
||||
|
||||
@@ -385,6 +386,12 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Extra entry for format
|
||||
Dictionary<string, object> arguments = new(3, StringComparer.Ordinal) {
|
||||
{ "access_token", accessToken! },
|
||||
{ "steamid", Bot.SteamID.ToString(CultureInfo.InvariantCulture) }
|
||||
};
|
||||
|
||||
KeyValue? response = null;
|
||||
|
||||
for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) {
|
||||
@@ -396,13 +403,9 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
response = await WebLimitRequest(
|
||||
WebAPI.DefaultBaseAddress,
|
||||
|
||||
// TODO: Remove this ToDictionary() call after https://github.com/SteamRE/SteamKit/pull/992 is released
|
||||
// ReSharper disable once AccessToDisposedClosure
|
||||
async () => await loyaltyRewardsService.CallAsync(
|
||||
HttpMethod.Get, "GetSummary", args: new Dictionary<string, object>(2, StringComparer.Ordinal) {
|
||||
{ "access_token", accessToken! },
|
||||
{ "steamid", Bot.SteamID.ToString(CultureInfo.InvariantCulture) }
|
||||
}
|
||||
).ConfigureAwait(false)
|
||||
async () => await loyaltyRewardsService.CallAsync(HttpMethod.Get, "GetSummary", args: arguments.ToDictionary(kv => kv.Key, kv => kv.Value)).ConfigureAwait(false)
|
||||
).ConfigureAwait(false);
|
||||
} catch (TaskCanceledException e) {
|
||||
Bot.ArchiLogger.LogGenericDebuggingException(e);
|
||||
@@ -413,16 +416,27 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
|
||||
if (response == null) {
|
||||
Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
KeyValue pointsInfo = response["summary"]["points"];
|
||||
|
||||
if (pointsInfo == KeyValue.Invalid) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(pointsInfo));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return uint.TryParse(pointsInfo.Value, out uint points) ? points : null;
|
||||
uint result = pointsInfo.AsUnsignedInteger(uint.MaxValue);
|
||||
|
||||
if (result == uint.MaxValue) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(result));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
@@ -2686,6 +2700,14 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
return await UrlPostWithSession(request, data: data).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<(bool Success, string? Result)> ResolveAccessToken() {
|
||||
Uri request = new(SteamStoreURL, "/pointssummary/ajaxgetasyncconfig");
|
||||
|
||||
ObjectResponse<AccessTokenResponse>? response = await UrlGetToJsonObjectWithSession<AccessTokenResponse>(request).ConfigureAwait(false);
|
||||
|
||||
return !string.IsNullOrEmpty(response?.Content.Data.WebAPIToken) ? (true, response!.Content.Data.WebAPIToken) : (false, null);
|
||||
}
|
||||
|
||||
private async Task<(bool Success, string? Result)> ResolveApiKey() {
|
||||
if (Bot.IsAccountLimited) {
|
||||
// API key is permanently unavailable for limited accounts
|
||||
@@ -2735,17 +2757,6 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
return (false, null);
|
||||
}
|
||||
}
|
||||
private async Task<(bool Success, string? Result)> ResolveAccessToken() {
|
||||
Uri request = new(SteamStoreURL, "/pointssummary/ajaxgetasyncconfig");
|
||||
|
||||
ObjectResponse<AccessTokenResponse>? response = await UrlGetToJsonObjectWithSession<AccessTokenResponse>(request).ConfigureAwait(false);
|
||||
|
||||
if (string.IsNullOrEmpty(response?.Content.AccessTokenData.WebAPIToken )) {
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
return (true, response!.Content.AccessTokenData.WebAPIToken );
|
||||
}
|
||||
|
||||
private async Task<bool> UnlockParentalAccount(string parentalCode) {
|
||||
if (string.IsNullOrEmpty(parentalCode)) {
|
||||
|
||||
Reference in New Issue
Block a user