mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Closes #2908
This commit is contained in:
parent
425b869218
commit
cd8c9cf80e
2 changed files with 41 additions and 0 deletions
|
@ -56,6 +56,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||
private const byte MinAnnouncementTTL = 5; // Minimum amount of minutes we must wait before the next Announcement
|
||||
private const byte MinHeartBeatTTL = 10; // Minimum amount of minutes we must wait before sending next HeartBeat
|
||||
private const byte MinimumSteamGuardEnabledDays = 15; // As imposed by Steam limits
|
||||
private const byte MinimumPasswordResetCooldownDays = 5; // As imposed by Steam limits
|
||||
private const byte MinPersonaStateTTL = 5; // Minimum amount of minutes we must wait before requesting persona state update
|
||||
|
||||
private static readonly ImmutableHashSet<Asset.EType> AcceptedMatchableTypes = ImmutableHashSet.Create(
|
||||
|
@ -561,6 +562,21 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||
return false;
|
||||
}
|
||||
|
||||
CCredentials_LastCredentialChangeTime_Response? lastCredentialChangeTime = await Bot.ArchiHandler.GetLastCredentialChangeTime().ConfigureAwait(false);
|
||||
|
||||
if (lastCredentialChangeTime == null) {
|
||||
Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(lastCredentialChangeTime)}: null"));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Bot didn't change password in last 5 days
|
||||
if ((lastCredentialChangeTime.timestamp_last_password_reset > 0) && ((DateTimeOffset.UtcNow - DateTimeOffset.FromUnixTimeSeconds(lastCredentialChangeTime.timestamp_last_password_reset)).TotalDays < MinimumPasswordResetCooldownDays)) {
|
||||
Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(lastCredentialChangeTime.timestamp_last_password_reset)}: {lastCredentialChangeTime.timestamp_last_password_reset}"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bot must have valid API key (e.g. not being restricted account)
|
||||
bool? hasValidApiKey = await Bot.ArchiWebHandler.HasValidApiKey().ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -91,6 +91,31 @@ public sealed class ArchiHandler : ClientMsgHandler {
|
|||
return response.Result == EResult.OK;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public async Task<CCredentials_LastCredentialChangeTime_Response?> GetLastCredentialChangeTime() {
|
||||
if (Client == null) {
|
||||
throw new InvalidOperationException(nameof(Client));
|
||||
}
|
||||
|
||||
if (!Client.IsConnected) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CCredentials_LastCredentialChangeTime_Request request = new();
|
||||
|
||||
SteamUnifiedMessages.ServiceMethodResponse response;
|
||||
|
||||
try {
|
||||
response = await UnifiedCredentialsService.SendMessage(x => x.GetCredentialChangeTimeDetails(request)).ToLongRunningTask().ConfigureAwait(false);
|
||||
} catch (Exception e) {
|
||||
ArchiLogger.LogGenericWarningException(e);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return response.Result == EResult.OK ? response.GetDeserializedResponse<CCredentials_LastCredentialChangeTime_Response>() : null;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public async Task<Dictionary<uint, string>?> GetOwnedGames(ulong steamID) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||
|
|
Loading…
Reference in a new issue