示例#1
0
        void placebetthread()
        {
            try
            {
                HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://betterbets.io/api/betDice/");//?"+string.Format("accessToken={3}&wager={0:0.00000000}&chance={1}&direction={2}", (amount), chance.ToString("0.00"), High ? "1" : "0", accesstoken));
                if (Prox != null)
                {
                    betrequest.Proxy = Prox;
                }
                betrequest.Method = "POST";
                double tmpchance = High ? 99.99 - chance : chance;
                string post      = string.Format("accessToken={3}&wager={0:0.00000000}&chance={1}&direction={2}", (amount), chance.ToString("0.00"), High ? "1" : "0", accesstoken);
                betrequest.ContentLength = post.Length;
                betrequest.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";

                using (var writer = new StreamWriter(betrequest.GetRequestStream()))
                {
                    writer.Write(post);
                }
                HttpWebResponse EmitResponse  = (HttpWebResponse)betrequest.GetResponse();
                string          sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();

                bbResult tmp = json.JsonDeserialize <bbResult>(sEmitResponse);


                next       = tmp.nextServerSeed;
                lastupdate = DateTime.Now;
                balance    = tmp.balance;
                bets++;
                if (tmp.win == 1)
                {
                    wins++;
                }
                else
                {
                    losses++;
                }

                wagered = (tmp.wager);
                profit  = tmp.profit;
                Bet tmp2 = tmp.toBet();
                tmp2.serverhash = next;
                next            = tmp.nextServerSeed;

                FinishedBet(tmp2);
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                }
                if (e.Message.Contains("429") || e.Message.Contains("502"))
                {
                    Thread.Sleep(200);
                    placebetthread();
                }
            }
        }
示例#2
0
        void placebetthread(object BetObj)
        {
            try
            {
                PlaceBetObj tmp9   = BetObj as PlaceBetObj;
                bool        High   = tmp9.High;
                decimal     amount = tmp9.Amount;
                decimal     chance = tmp9.Chance;
                byte[]      bytes  = new byte[4];
                R.GetBytes(bytes);
                long client = (long)BitConverter.ToUInt32(bytes, 0);
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("accessToken", accesstoken));
                pairs.Add(new KeyValuePair <string, string>("wager", amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("chance", chance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("direction", High?"1":"0"));
                pairs.Add(new KeyValuePair <string, string>("coin", Currency));
                pairs.Add(new KeyValuePair <string, string>("clientSeed", client.ToString()));
                R.GetBytes(bytes);
                client = (long)BitConverter.ToUInt32(bytes, 0);
                if (Currency == "btc")
                {
                    pairs.Add(new KeyValuePair <string, string>("clientSeedNext", client.ToString()));
                }
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string responseData           = "";
                using (var response = Client.PostAsync("betDice", Content))
                {
                    while (!response.IsCompleted)
                    {
                        Thread.Sleep(100);
                    }
                    try
                    {
                        responseData = response.Result.Content.ReadAsStringAsync().Result;
                    }
                    catch (AggregateException e)
                    {
                        if (retrycount++ < 3)
                        {
                            placebetthread(new PlaceBetObj(High, amount, chance));
                            return;
                        }
                        if (e.InnerException.Message.Contains("ssl"))
                        {
                            placebetthread(new PlaceBetObj(High, amount, chance));
                            return;
                        }
                    }
                }

                bbResult tmp = json.JsonDeserialize <bbResult>(responseData);

                if (tmp.error != 1)
                {
                    next       = tmp.nextServerSeed;
                    lastupdate = DateTime.Now;
                    balance    = tmp.balance;
                    bets++;
                    if (tmp.win == 1)
                    {
                        wins++;
                    }
                    else
                    {
                        losses++;
                    }

                    wagered += (tmp.wager);
                    profit  += tmp.profit;


                    Bet tmp2 = tmp.toBet();
                    tmp2.date       = DateTime.Now;
                    tmp2.serverhash = next;
                    next            = tmp.nextServerSeed;

                    FinishedBet(tmp2);
                    retrycount = 0;
                }
                else
                {
                    Parent.updateStatus("An error has occured! Betting has stopped for your safety.");
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                }
                if (e.Message.Contains("429") || e.Message.Contains("502"))
                {
                    Thread.Sleep(200);
                    placebetthread(new PlaceBetObj(High, amount, chance));
                }
            }
            catch (Exception e)
            {
            }
        }
示例#3
0
        void placebetthread()
        {
            try
            {
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("accessToken", accesstoken));
                pairs.Add(new KeyValuePair <string, string>("wager", amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("chance", chance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("direction", High?"1":"0"));
                pairs.Add(new KeyValuePair <string, string>("coin", Currency));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string responseData           = "";
                using (var response = Client.PostAsync("betDice/", Content))
                {
                    try
                    {
                        responseData = response.Result.Content.ReadAsStringAsync().Result;
                    }
                    catch (AggregateException e)
                    {
                        if (retrycount++ < 3)
                        {
                            placebetthread();
                            return;
                        }
                        if (e.InnerException.Message.Contains("ssl"))
                        {
                            placebetthread();
                            return;
                        }
                    }
                }

                bbResult tmp = json.JsonDeserialize <bbResult>(responseData);
                if (tmp.error != 1)
                {
                    next       = tmp.nextServerSeed;
                    lastupdate = DateTime.Now;
                    balance    = tmp.balance;
                    bets++;
                    if (tmp.win == 1)
                    {
                        wins++;
                    }
                    else
                    {
                        losses++;
                    }

                    wagered += (tmp.wager);
                    profit  += tmp.profit;


                    Bet tmp2 = tmp.toBet();
                    tmp2.serverhash = next;
                    next            = tmp.nextServerSeed;

                    FinishedBet(tmp2);
                    retrycount = 0;
                }
                else
                {
                    Parent.updateStatus("An error has occured! Betting has stopped for your safety.");
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                }
                if (e.Message.Contains("429") || e.Message.Contains("502"))
                {
                    Thread.Sleep(200);
                    placebetthread();
                }
            }
            catch (Exception e)
            {
            }
        }