mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-15 16:10:41 +00:00
Avoid excessive parental request
We can make use of the one in logged-in, which is superior
This commit is contained in:
@@ -43,7 +43,6 @@ namespace ArchiSteamFarm {
|
||||
private readonly SteamUnifiedMessages.UnifiedService<IClanChatRooms> UnifiedClanChatRoomsService;
|
||||
private readonly SteamUnifiedMessages.UnifiedService<IEcon> UnifiedEconService;
|
||||
private readonly SteamUnifiedMessages.UnifiedService<IFriendMessages> UnifiedFriendMessagesService;
|
||||
private readonly SteamUnifiedMessages.UnifiedService<IParental> UnifiedParentalService;
|
||||
private readonly SteamUnifiedMessages.UnifiedService<IPlayer> UnifiedPlayerService;
|
||||
|
||||
internal DateTime LastPacketReceived { get; private set; }
|
||||
@@ -58,7 +57,6 @@ namespace ArchiSteamFarm {
|
||||
UnifiedClanChatRoomsService = steamUnifiedMessages.CreateService<IClanChatRooms>();
|
||||
UnifiedEconService = steamUnifiedMessages.CreateService<IEcon>();
|
||||
UnifiedFriendMessagesService = steamUnifiedMessages.CreateService<IFriendMessages>();
|
||||
UnifiedParentalService = steamUnifiedMessages.CreateService<IParental>();
|
||||
UnifiedPlayerService = steamUnifiedMessages.CreateService<IPlayer>();
|
||||
}
|
||||
|
||||
@@ -631,90 +629,6 @@ namespace ArchiSteamFarm {
|
||||
Client.Send(request);
|
||||
}
|
||||
|
||||
internal async Task<(bool IsSteamParentalEnabled, string SteamParentalCode)?> ValidateSteamParental(string steamParentalCode = null) {
|
||||
if (!Client.IsConnected) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CParental_GetParentalSettings_Request request = new CParental_GetParentalSettings_Request { steamid = Client.SteamID };
|
||||
|
||||
SteamUnifiedMessages.ServiceMethodResponse response;
|
||||
|
||||
try {
|
||||
response = await UnifiedParentalService.SendMessage(x => x.GetParentalSettings(request));
|
||||
} catch (Exception e) {
|
||||
ArchiLogger.LogGenericWarningException(e);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
ArchiLogger.LogNullError(nameof(response));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.Result != EResult.OK) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CParental_GetParentalSettings_Response body = response.GetDeserializedResponse<CParental_GetParentalSettings_Response>();
|
||||
|
||||
if (body.settings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!body.settings.is_enabled) {
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
ArchiCryptoHelper.ESteamParentalAlgorithm steamParentalAlgorithm;
|
||||
|
||||
switch (body.settings.passwordhashtype) {
|
||||
case 4:
|
||||
steamParentalAlgorithm = ArchiCryptoHelper.ESteamParentalAlgorithm.Pbkdf2;
|
||||
|
||||
break;
|
||||
case 6:
|
||||
steamParentalAlgorithm = ArchiCryptoHelper.ESteamParentalAlgorithm.SCrypt;
|
||||
|
||||
break;
|
||||
default:
|
||||
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(body.settings.passwordhashtype), body.settings.passwordhashtype));
|
||||
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
if ((steamParentalCode != null) && (steamParentalCode.Length == BotConfig.SteamParentalCodeLength)) {
|
||||
byte i = 0;
|
||||
byte[] password = new byte[steamParentalCode.Length];
|
||||
|
||||
foreach (char character in steamParentalCode) {
|
||||
if ((character < '0') || (character > '9')) {
|
||||
break;
|
||||
}
|
||||
|
||||
password[i++] = (byte) character;
|
||||
}
|
||||
|
||||
if (i >= steamParentalCode.Length) {
|
||||
byte[] passwordHash = ArchiCryptoHelper.GenerateSteamParentalHash(password, body.settings.salt, (byte) body.settings.passwordhash.Length, steamParentalAlgorithm);
|
||||
|
||||
if (passwordHash.SequenceEqual(body.settings.passwordhash)) {
|
||||
return (true, steamParentalCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArchiLogger.LogGenericInfo(Strings.BotGeneratingSteamParentalCode);
|
||||
|
||||
steamParentalCode = ArchiCryptoHelper.RecoverSteamParentalCode(body.settings.passwordhash, body.settings.salt, steamParentalAlgorithm);
|
||||
|
||||
ArchiLogger.LogGenericInfo(Strings.Done);
|
||||
|
||||
return (true, steamParentalCode);
|
||||
}
|
||||
|
||||
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
|
||||
if (packetMsg == null) {
|
||||
ArchiLogger.LogNullError(nameof(packetMsg));
|
||||
|
||||
Reference in New Issue
Block a user