示例#1
0
        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://dadice.com/api/")
            };
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
            username = Username;
            key      = Password;
            List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();

            pairs.Add(new KeyValuePair <string, string>("username", username));
            pairs.Add(new KeyValuePair <string, string>("key", key));
            FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
            DADICEBlance          tmp     = new DADICEBlance();

            using (var response = Client.PostAsync("balance", Content))
            {
                string Resp = response.Result.Content.ReadAsStringAsync().Result;
                tmp = json.JsonDeserialize <DADICEBlance>(Resp);
            }
            if (tmp.status)
            {
                pairs.Add(new KeyValuePair <string, string>("coin", "btc"));
                Content = new FormUrlEncodedContent(pairs);
                DADICEBlance dep = new DADICEBlance();
                using (var response = Client.PostAsync("deposit", Content))
                {
                    string Resp = response.Result.Content.ReadAsStringAsync().Result;
                    dep = json.JsonDeserialize <DADICEBlance>(Resp);
                }

                if (dep.status)
                {
                    Parent.updateDeposit(dep.address);
                }

                balance = (decimal)tmp.balance;


                HttpWebRequest loginrequest = (HttpWebRequest)HttpWebRequest.Create("https://stats.dadice.com/api/userinfo?username="******"application/x-www-form-urlencoded; charset=UTF-8";


                HttpWebResponse EmitResponse = (HttpWebResponse)loginrequest.GetResponse();

                string sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();
                LastBalance = DateTime.Now.AddSeconds(-20);
                DADICEStatsBase tmp2 = json.JsonDeserialize <DADICEStatsBase>(sEmitResponse);
                this.wagered = decimal.Parse(tmp2.user.stats.wagered, System.Globalization.NumberFormatInfo.InvariantInfo);
                this.bets    = tmp2.user.stats.bets;
                this.wins    = tmp2.user.stats.won;
                this.losses  = tmp2.user.stats.lost;
                this.profit  = decimal.Parse(tmp2.user.stats.profit);

                Parent.updateBalance((decimal)(balance));
                Parent.updateBets(bets);
                Parent.updateLosses(losses);
                Parent.updateProfit(profit);
                Parent.updateWagered(wagered);
                Parent.updateWins(wins);
                Parent.updateBalance(balance);
                finishedlogin(true);
            }
            else
            {
                finishedlogin(false);
            }
        }
示例#2
0
文件: dadice.cs 项目: wmgjang/DiceBot
        public override void Login(string Username, string Password, string twofa)
        {
            username = Username;
            key      = Password;

            HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://dadice.com/api/balance");

            betrequest.Method = "POST";
            string post = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "username={0}&key={1}", username, key);

            betrequest.ContentLength = post.Length;
            if (Prox != null)
            {
                betrequest.Proxy = Prox;
            }
            betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            using (var writer = new StreamWriter(betrequest.GetRequestStream()))
            {
                writer.Write(post);
            }
            HttpWebResponse EmitResponse2  = (HttpWebResponse)betrequest.GetResponse();
            string          sEmitResponse2 = new StreamReader(EmitResponse2.GetResponseStream()).ReadToEnd();
            DADICEBlance    tmp            = json.JsonDeserialize <DADICEBlance>(sEmitResponse2);

            if (tmp.status)
            {
                HttpWebRequest betrequest2 = (HttpWebRequest)HttpWebRequest.Create("https://dadice.com/api/deposit");
                betrequest2.Method = "POST";
                string post2 = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "username={0}&key={1}&coin=btc", username, key);
                betrequest2.ContentLength = post.Length;
                if (Prox != null)
                {
                    betrequest.Proxy = Prox;
                }
                betrequest2.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                using (var writer = new StreamWriter(betrequest2.GetRequestStream()))
                {
                    writer.Write(post);
                }
                HttpWebResponse EmitResponse3  = (HttpWebResponse)betrequest2.GetResponse();
                string          sEmitResponse3 = new StreamReader(EmitResponse3.GetResponseStream()).ReadToEnd();
                DADICEBlance    dep            = json.JsonDeserialize <DADICEBlance>(sEmitResponse3);
                if (dep.status)
                {
                    Parent.updateDeposit(dep.address);
                }


                balance = (double)tmp.balance;
                HttpWebRequest loginrequest = (HttpWebRequest)HttpWebRequest.Create("https://stats.dadice.com/api/userinfo?username="******"application/x-www-form-urlencoded; charset=UTF-8";


                HttpWebResponse EmitResponse = (HttpWebResponse)loginrequest.GetResponse();

                string sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();
                LastBalance = DateTime.Now.AddSeconds(-20);
                DADICEStatsBase tmp2 = json.JsonDeserialize <DADICEStatsBase>(sEmitResponse);
                this.wagered = double.Parse(tmp2.user.stats.wagered, System.Globalization.NumberFormatInfo.InvariantInfo);
                this.bets    = tmp2.user.stats.bets;
                this.wins    = tmp2.user.stats.won;
                this.losses  = tmp2.user.stats.lost;
                this.profit  = double.Parse(tmp2.user.stats.profit);

                Parent.updateBalance((decimal)(balance));
                Parent.updateBets(bets);
                Parent.updateLosses(losses);
                Parent.updateProfit(profit);
                Parent.updateWagered(wagered);
                Parent.updateWins(wins);
                Parent.updateBalance(balance);
                finishedlogin(true);
            }
            else
            {
                finishedlogin(false);
            }
        }