@@ -28,6 +28,7 @@ limitations under the License.
2828using System . Collections . Generic ;
2929using System . Globalization ;
3030using System . Net ;
31+ using System . Net . Http ;
3132using System . Text ;
3233using System . Threading . Tasks ;
3334
@@ -62,7 +63,7 @@ internal ArchiWebHandler(Bot bot, string apiKey) {
6263 }
6364 }
6465
65- internal void Init ( SteamClient steamClient , string webAPIUserNonce , string vanityURL ) {
66+ internal async Task Init ( SteamClient steamClient , string webAPIUserNonce , string vanityURL , string parentalPin ) {
6667 if ( steamClient == null || steamClient . SteamID == null || string . IsNullOrEmpty ( webAPIUserNonce ) ) {
6768 return ;
6869 }
@@ -125,6 +126,30 @@ internal void Init(SteamClient steamClient, string webAPIUserNonce, string vanit
125126 SteamCookieDictionary . Add ( "steamLoginSecure" , steamLoginSecure ) ;
126127 SteamCookieDictionary . Add ( "birthtime" , "-473356799" ) ; // ( ͡° ͜ʖ ͡°)
127128
129+ if ( ! string . IsNullOrEmpty ( parentalPin ) && ! parentalPin . Equals ( "0" ) ) {
130+ Logging . LogGenericInfo ( Bot . BotName , "Unlocking parental account..." ) ;
131+ Dictionary < string , string > postData = new Dictionary < string , string > ( ) {
132+ { "pin" , parentalPin }
133+ } ;
134+
135+ HttpResponseMessage response = await Utilities . UrlPostRequestWithResponse ( "https://steamcommunity.com/parental/ajaxunlock" , postData , SteamCookieDictionary , "https://steamcommunity.com/" ) . ConfigureAwait ( false ) ;
136+ if ( response != null && response . IsSuccessStatusCode ) {
137+ Logging . LogGenericInfo ( Bot . BotName , "Success!" ) ;
138+
139+ var setCookieValues = response . Headers . GetValues ( "Set-Cookie" ) ;
140+ foreach ( string setCookieValue in setCookieValues ) {
141+ if ( setCookieValue . Contains ( "steamparental=" ) ) {
142+ string setCookie = setCookieValue . Substring ( setCookieValue . IndexOf ( "steamparental=" ) + 14 ) ;
143+ setCookie = setCookie . Substring ( 0 , setCookie . IndexOf ( ';' ) ) ;
144+ SteamCookieDictionary . Add ( "steamparental" , setCookie ) ;
145+ break ;
146+ }
147+ }
148+ } else {
149+ Logging . LogGenericInfo ( Bot . BotName , "Failed!" ) ;
150+ }
151+ }
152+
128153 Bot . Trading . CheckTrades ( ) ;
129154 }
130155
0 commit comments