コード例 #1
0
ファイル: Kingdice.cs プロジェクト: zlata123/DiceBot
        void GetBalanceThread()
        {
            while (iskd)
            {
                try
                {
                    if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 15 || ForceUpdateStats))
                    {
                        lastupdate = DateTime.Now;
                        List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                        pairs.Add(new KeyValuePair <string, string>("token", accesstoken));

                        FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                        string    sEmitResponse       = Client.PostAsync("balance.php", Content).Result.Content.ReadAsStringAsync().Result;
                        KDBalance tmpbal = json.JsonDeserialize <KDBalance>(sEmitResponse);
                        if (tmpbal.code == "SUCCESS")
                        {
                            pairs = new List <KeyValuePair <string, string> >();
                            pairs.Add(new KeyValuePair <string, string>("username", username));
                            pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                            Content       = new FormUrlEncodedContent(pairs);
                            sEmitResponse = Client.PostAsync("stats/profile.php", Content).Result.Content.ReadAsStringAsync().Result;
                            KDStat tmpstats = json.JsonDeserialize <KDStat>(sEmitResponse);
                            wagered = tmpstats.wagered / 100000000m;
                            profit  = tmpstats.profit / 100000000m;
                            bets    = (int)tmpstats.rolls;
                            Parent.updateBets(bets);
                            Parent.updateProfit(profit);
                            Parent.updateWagered(wagered);
                            balance = tmpbal.balance / 100000000m;
                            Parent.updateBalance(balance);
                        }
                    }
                }
                catch { }
                Thread.Sleep(1000);
            }
        }
コード例 #2
0
ファイル: Kingdice.cs プロジェクト: zlata123/DiceBot
        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://kingdice.com/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("Host", "kingdice.com");
            Client.DefaultRequestHeaders.Add("Origin", "https://kingdice.com");
            Client.DefaultRequestHeaders.Add("Referer", "https://kingdice.com");

            try
            {
                this.username = Username;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("username", Username));
                pairs.Add(new KeyValuePair <string, string>("password", Password));
                pairs.Add(new KeyValuePair <string, string>("sdb", "8043d46408307f3ac9d14931ba27c9015349bf21b7b7"));
                pairs.Add(new KeyValuePair <string, string>("2facode", twofa /*==""?"undefined":twofa*/));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string sEmitResponse          = Client.PostAsync("login.php", Content).Result.Content.ReadAsStringAsync().Result;

                KDLogin tmplogin = json.JsonDeserialize <KDLogin>(sEmitResponse);
                if (tmplogin.code == "SUCCESS")
                {
                    accesstoken = tmplogin.token;
                    pairs       = new List <KeyValuePair <string, string> >();
                    pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                    Content       = new FormUrlEncodedContent(pairs);
                    sEmitResponse = Client.PostAsync("logged.php", Content).Result.Content.ReadAsStringAsync().Result;
                    //sEmitResponse2 = Client.GetStringAsync("logged.php").Result;
                    KDLoggedIn tmpStats = json.JsonDeserialize <KDLoggedIn>(sEmitResponse);
                    if (tmpStats.code == "SUCCESS")
                    {
                        balance = tmpStats.balance / 100000000m;
                        if (tmpStats.address != null)
                        {
                            Parent.updateDeposit(tmpStats.address);
                        }
                        pairs = new List <KeyValuePair <string, string> >();
                        pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                        Content       = new FormUrlEncodedContent(pairs);
                        sEmitResponse = Client.PostAsync("nextroll.php", Content).Result.Content.ReadAsStringAsync().Result;
                        KDNextRoll tmphash = json.JsonDeserialize <KDNextRoll>(sEmitResponse);
                        if (tmphash.code == "SUCCESS")
                        {
                            LastHash = tmphash.round_hash;
                            pairs    = new List <KeyValuePair <string, string> >();
                            pairs.Add(new KeyValuePair <string, string>("username", username));
                            pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                            Content       = new FormUrlEncodedContent(pairs);
                            sEmitResponse = Client.PostAsync("stats/profile.php", Content).Result.Content.ReadAsStringAsync().Result;
                            KDStat tmpstats = json.JsonDeserialize <KDStat>(sEmitResponse);
                            wagered = tmpstats.wagered / 100000000m;
                            profit  = tmpstats.profit / 100000000m;
                            bets    = (int)tmpstats.rolls;
                            Parent.updateBets(bets);
                            Parent.updateProfit(profit);
                            Parent.updateWagered(wagered);
                            iskd = true;
                            Thread t = new Thread(GetBalanceThread);
                            t.Start();
                            Parent.updateBalance(balance);
                            finishedlogin(true);
                            return;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), 1);
            }
            finishedlogin(false);
        }