void GetBalanceThread() { while (ispd) { if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 60 || ForceUpdateStats)) { try { ForceUpdateStats = false; lastupdate = DateTime.Now; string sEmitResponse = Client.GetStringAsync("load/" + Currency + "?api_key=" + accesstoken + "&api_version=" + apiversion).Result; Quackbalance balance = json.JsonDeserialize <Quackbalance>(sEmitResponse); this.balance = decimal.Parse(this.Mode == 1 ? balance.user.balances.main : balance.user.balances.faucet, System.Globalization.NumberFormatInfo.InvariantInfo); Parent.updateBalance(this.balance); sEmitResponse = Client.GetStringAsync("stat/" + Currency + "?api_key=" + accesstoken).Result; QuackStatsDetails Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse); this.profit = decimal.Parse(Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo); this.wagered = decimal.Parse(Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo); bets = Stats.bets; wins = Stats.wins; losses = bets - wins; Parent.updateProfit(this.profit); Parent.updateBets(this.bets); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateWins(wins); } catch { } } Thread.Sleep(1000); } }
protected override void CurrencyChanged() { try { if (ispd) { string sEmitResponse = Client.GetStringAsync("load/" + Currency + "?api_key=" + accesstoken).Result; Quackbalance balance = json.JsonDeserialize <Quackbalance>(sEmitResponse); this.balance = decimal.Parse(this.Mode == 1? balance.user.balances.main: balance.user.balances.faucet, System.Globalization.NumberFormatInfo.InvariantInfo); Parent.updateBalance(this.balance); sEmitResponse = Client.GetStringAsync("stat/" + Currency + "?api_key=" + accesstoken).Result; QuackStatsDetails Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse); this.profit = decimal.Parse(Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo); this.wagered = decimal.Parse(Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo); bets = Stats.bets; wins = Stats.wins; losses = bets - wins; Parent.updateProfit(this.profit); Parent.updateBets(this.bets); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateWins(wins); } } catch { } }
public override void Login(string Username, string Password, string twofa) { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://duckdice.io/api/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"); try { accesstoken = Password; //Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer",accesstoken); accesstoken = Password; string sEmitResponse = Client.GetStringAsync("load/" + Currency + "?api_key=" + accesstoken).Result; Quackbalance balance = json.JsonDeserialize <Quackbalance>(sEmitResponse); sEmitResponse = Client.GetStringAsync("stat/" + Currency + "?api_key=" + accesstoken).Result; QuackStatsDetails Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse); sEmitResponse = Client.GetStringAsync("randomize" + "?api_key=" + accesstoken).Result; currentseed = json.JsonDeserialize <QuackSeed>(sEmitResponse).current; if (balance != null && Stats != null) { this.balance = decimal.Parse(balance.user.balance, System.Globalization.NumberFormatInfo.InvariantInfo); this.profit = decimal.Parse(Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo); this.wagered = decimal.Parse(Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo); bets = Stats.bets; wins = Stats.wins; losses = bets - wins; Parent.updateBalance(this.balance); Parent.updateProfit(this.profit); Parent.updateBets(this.bets); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateWins(wins); ispd = true; lastupdate = DateTime.Now; new Thread(new ThreadStart(GetBalanceThread)).Start(); finishedlogin(true); return; } /*} * }*/ } catch (Exception e) { finishedlogin(false); return; } finishedlogin(false); return; }
public override void Login(string Username, string Password, string twofa) { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null }; ClientHandlr.CookieContainer = new CookieContainer(); Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://duckdice.io/api/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"); //Client.DefaultRequestHeaders.Add("origin", "https://duckdice.io"); try { accesstoken = Password; //Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer",accesstoken); accesstoken = Password; /*string s1 = ""; * HttpResponseMessage resp = Client.GetAsync("https://duckdice.io/api/play").Result; * if (resp.IsSuccessStatusCode) * { * s1 = resp.Content.ReadAsStringAsync().Result; * } * else * { * if (resp.StatusCode == HttpStatusCode.ServiceUnavailable) * { * s1 = resp.Content.ReadAsStringAsync().Result; * //cflevel = 0; * System.Threading.Tasks.Task.Factory.StartNew(() => * { * System.Windows.Forms.MessageBox.Show("Duckdice.io has their cloudflare protection on HIGH\n\nThis will cause a slight delay in logging in. Please allow up to a minute."); * }); * if (!Cloudflare.doCFThing(s1, Client, ClientHandlr, 0, "www.duckdice.io")) * { * finishedlogin(false); * return; * } * } * else * { * * } * }*/ string sEmitResponse = Client.GetStringAsync("load/" + Currency + "?api_key=" + accesstoken).Result; Quackbalance balance = json.JsonDeserialize <Quackbalance>(sEmitResponse); sEmitResponse = Client.GetStringAsync("stat/" + Currency + "?api_key=" + accesstoken).Result; QuackStatsDetails Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse); sEmitResponse = Client.GetStringAsync("randomize" + "?api_key=" + accesstoken).Result; currentseed = json.JsonDeserialize <QuackSeed>(sEmitResponse).current; if (balance != null && Stats != null) { this.balance = decimal.Parse(balance.user.balance, System.Globalization.NumberFormatInfo.InvariantInfo); this.profit = decimal.Parse(Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo); this.wagered = decimal.Parse(Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo); bets = Stats.bets; wins = Stats.wins; losses = bets - wins; Parent.updateBalance(this.balance); Parent.updateProfit(this.profit); Parent.updateBets(this.bets); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateWins(wins); ispd = true; lastupdate = DateTime.Now; new Thread(new ThreadStart(GetBalanceThread)).Start(); finishedlogin(true); return; } /*} * }*/ } catch (Exception e) { finishedlogin(false); return; } finishedlogin(false); return; }
public override void Login(string Username, string Password, string twofa) { ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://duckdice.io/api/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"); try { StringContent Content = new StringContent("{\"username\":\"" + Username + "\",\"password\":\"" + Password + "\",\"campaignHash\":\"53ea652da4\"}", Encoding.UTF8, "application/json"); string sEmitResponse = Client.PostAsync("login" + accesstoken, Content).Result.Content.ReadAsStringAsync().Result; QuackLogin tmplogin = null; try { tmplogin = json.JsonDeserialize <QuackLogin>(sEmitResponse); } catch (Exception e) { finishedlogin(false); return; } if (tmplogin != null) { if (tmplogin.token != null) { accesstoken = tmplogin.token; Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accesstoken); sEmitResponse = Client.GetStringAsync("load/" + Currency).Result; Quackbalance balance = json.JsonDeserialize <Quackbalance>(sEmitResponse); sEmitResponse = Client.GetStringAsync("stat/" + Currency).Result; QuackStatsDetails Stats = json.JsonDeserialize <QuackStatsDetails>(sEmitResponse); sEmitResponse = Client.GetStringAsync("randomize").Result; currentseed = json.JsonDeserialize <QuackSeed>(sEmitResponse).current; if (balance != null && Stats != null) { this.balance = decimal.Parse(balance.user.balance, System.Globalization.NumberFormatInfo.InvariantInfo); this.profit = decimal.Parse(Stats.profit, System.Globalization.NumberFormatInfo.InvariantInfo); this.wagered = decimal.Parse(Stats.volume, System.Globalization.NumberFormatInfo.InvariantInfo); bets = Stats.bets; wins = Stats.wins; losses = bets - wins; Parent.updateBalance(this.balance); Parent.updateProfit(this.profit); Parent.updateBets(this.bets); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateWins(wins); ispd = true; lastupdate = DateTime.Now; new Thread(new ThreadStart(GetBalanceThread)).Start(); finishedlogin(true); return; } } } } catch (Exception e) { finishedlogin(false); return; } finishedlogin(false); return; }