@@ -325,6 +325,57 @@ internal Dictionary<uint, string> GetOwnedGames(ulong steamID) {
325325 return result ;
326326 }
327327
328+ internal async Task < byte ? > GetTradeHoldDuration ( ulong tradeID ) {
329+ if ( tradeID == 0 ) {
330+ Logging . LogNullError ( nameof ( tradeID ) , Bot . BotName ) ;
331+ return null ;
332+ }
333+
334+ string request = SteamCommunityURL + "/tradeoffer/" + tradeID ;
335+
336+ HtmlDocument htmlDocument = await WebBrowser . UrlGetToHtmlDocumentRetry ( request ) . ConfigureAwait ( false ) ;
337+ if ( htmlDocument == null ) {
338+ return null ;
339+ }
340+
341+ HtmlNode htmlNode = htmlDocument . DocumentNode . SelectSingleNode ( "//div[@class='pagecontent']/script" ) ;
342+ if ( htmlNode == null ) {
343+ Logging . LogNullError ( nameof ( htmlNode ) , Bot . BotName ) ;
344+ return null ;
345+ }
346+
347+ string text = htmlNode . InnerText ;
348+ if ( string . IsNullOrEmpty ( text ) ) {
349+ Logging . LogNullError ( nameof ( text ) , Bot . BotName ) ;
350+ return null ;
351+ }
352+
353+ int index = text . IndexOf ( "g_daysTheirEscrow = " , StringComparison . Ordinal ) ;
354+ if ( index < 0 ) {
355+ Logging . LogNullError ( nameof ( index ) , Bot . BotName ) ;
356+ return null ;
357+ }
358+
359+ index += 20 ;
360+ text = text . Substring ( index ) ;
361+
362+ index = text . IndexOf ( ';' ) ;
363+ if ( index < 0 ) {
364+ Logging . LogNullError ( nameof ( index ) , Bot . BotName ) ;
365+ return null ;
366+ }
367+
368+ text = text . Substring ( 0 , index ) ;
369+
370+ byte holdDuration ;
371+ if ( byte . TryParse ( text , out holdDuration ) ) {
372+ return holdDuration ;
373+ }
374+
375+ Logging . LogNullError ( nameof ( holdDuration ) , Bot . BotName ) ;
376+ return null ;
377+ }
378+
328379 internal HashSet < Steam . TradeOffer > GetTradeOffers ( ) {
329380 if ( string . IsNullOrEmpty ( Bot . BotConfig . SteamApiKey ) ) {
330381 // TODO: Correct this when Mono 4.4+ will be a latest stable one | https://bugzilla.xamarin.com/show_bug.cgi?id=39455
0 commit comments