protected override void _UpdateStats() { try { ForceUpdateStats = false; lastupdate = DateTime.Now; string sEmitResponse2 = Client.GetStringAsync("api/stats").Result; NDGetBalance tmpu = json.JsonDeserialize <NDGetBalance>(sEmitResponse2); try { sEmitResponse2 = Client.GetStringAsync("sshash").Result; NDGetHash tmpHash = json.JsonDeserialize <NDGetHash>(sEmitResponse2); lastHash = tmpHash.sshash; } catch (Exception e) { Logger.DumpLog(e); } Stats.Balance = tmpu.balance; Stats.Profit = tmpu.amountLost + tmpu.amountWon; Stats.Wins = (int)tmpu.totWins; Stats.Losses = (int)tmpu.totLosses; Stats.Bets = (int)tmpu.totBets; } catch (Exception e) { Logger.DumpLog(e); } }
protected override void _Login(LoginParamValue[] LoginParams) { ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://www.nitrodice.com/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); string Username = ""; string Password = ""; string otp = ""; foreach (LoginParamValue x in LoginParams) { if (x.Param.Name.ToLower() == "username") { Username = x.Value; } if (x.Param.Name.ToLower() == "password") { Password = x.Value; } if (x.Param.Name.ToLower() == "2fa code") { otp = x.Value; } } try { string jsoncontent = json.JsonSerializer <NDAuth>(new NDAuth() { pass = Password, user = Username, tfa = otp }); StringContent Content = new StringContent(jsoncontent, Encoding.UTF8, "application/json"); string Response = Client.PostAsync("api/auth", Content).Result.Content.ReadAsStringAsync().Result; NDGetAuth getauth = json.JsonDeserialize <NDGetAuth>(Response); if (getauth != null) { if (getauth.token != null) { Client.DefaultRequestHeaders.Add("x-token", getauth.token); Client.DefaultRequestHeaders.Add("x-user", Username); accesstoken = getauth.token; string sEmitResponse2 = Client.GetStringAsync("api/stats").Result; NDGetBalance tmpu = json.JsonDeserialize <NDGetBalance>(sEmitResponse2); try { sEmitResponse2 = Client.GetStringAsync("sshash").Result; NDGetHash tmpHash = json.JsonDeserialize <NDGetHash>(sEmitResponse2); lastHash = tmpHash.sshash; } catch (Exception e) { } Stats.Balance = tmpu.balance; Stats.Profit = tmpu.amountLost + tmpu.amountWon; Stats.Wins = (int)tmpu.totWins; Stats.Losses = (int)tmpu.totLosses; Stats.Bets = (int)tmpu.totBets; lastupdate = DateTime.Now; ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); callLoginFinished(true); return; } } } catch (Exception e) { Logger.DumpLog(e); callError(e.ToString(), true, ErrorType.Other); } callLoginFinished(false); }