示例#1
0
        public FormMain(FutClient client, string[] account)
        {
            InitializeComponent();
            _client                 = client;
            this._account           = account;
            StyleManager            = metroStyleManager;
            metroStyleManager.Style = Properties.Settings.Default.MetroColor;
            metroStyleManager.Theme = Properties.Settings.Default.MetroTheme;
            mgTable.BorderStyle     = System.Windows.Forms.BorderStyle.Fixed3D;

            tbSearch.Text         = (Math.Round((double)_searchMs / 1000, 1)).ToString(CultureInfo.InvariantCulture);
            tbChecktradepile.Text = (_tradepileMs / 1000).ToString();

            numericUpDownPricefix.Value = _maxplayersonrequest;
            tmrChecktradepile.Interval  = _tradepileMs;
            tmrSearchRequest.Interval   = _searchMs;
            cbCheckforUpdates.Checked   = _checkforupdates;
            cbPlaySound.Checked         = _playSound;
            cbResetCounter.Checked      = _resetCounter;
            cbDebug.Checked             = _debug;
            lblAccount.Text             = account[0];
            lblVersion.Text             = @"Version " + ProductVersion;
            if (_client != null)
            {
                GetCredits();
            }
        }
示例#2
0
        public async void DoRelog()
        {
            lblTimer.Text = @"";
            lblRelog.Text = @"Performing relog";
            WriteLog.DoWrite("Performing relog");
            Platform platform = Platform.Pc;

            switch (int.Parse(_account[3]))
            {
            case 0:
                platform = Platform.Pc;
                break;

            case 1:
                platform = Platform.Ps3;
                break;

            case 2:
                platform = Platform.Ps4;
                break;

            case 3:
                platform = Platform.Xbox360;
                break;

            case 4:
                platform = Platform.XboxOne;
                break;
            }


            try
            {
                CookieContainer cookie = CookieUtil.ReadCookiesFromDisk("cookies\\" + _account[0] + "_cookie.dat");
                Client = new FutClient(cookie);
                var loginDetails = new LoginDetails(_account[0], _account[1], _account[2], platform);
                await Client.LoginAsync(loginDetails, null);

                this.Close();
            }
            catch (Exception)
            {
                if (_i >= 5)
                {
                    WriteLog.DoWrite("Relog failed 5 times, exiting FutBud");
                    Application.Exit();
                }
                WriteLog.DoWrite("Relog failed");
                lblRelog.Text = (@"Relog failed");
                var start = DateTime.UtcNow;
                _endTime             = start.AddMinutes(5);
                tmrCountdown.Enabled = true;
                _i++;
            }
        }
    FutClient client;    //<-- declared it here
    public async void button1_Click(object sender, EventArgs e)
    {
        client = new FutClient();    // <--I changed this
        var loginDetails = new LoginDetails(email, password, secret, platform);

        try
        {
            var loginResponse = await client.LoginAsync(loginDetails);

            var creditsResponse = await client.GetCreditsAsync();

            label1.Text = creditsResponse.Credits.ToString();
        }
        catch (Exception ex)
        {
            this.textBox4.Text = ex.Message;
            //throw;
        }
    }
示例#4
0
        static void Main(string[] args)
        {
            var client = new FutClient();

            try
            {
                LoginManager.ConnectionAsync(client).Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }


            var creditsResponse = client.GetCreditsAsync().GetAwaiter().GetResult();

            Console.WriteLine($"Crediti: {creditsResponse.Credits}");

            var squadListResponse = client.GetSquadListAsync().GetAwaiter().GetResult();

            foreach (var squad in squadListResponse.Squad)
            {
                Console.WriteLine($"{squad.SquadName}");

                //squad.Id nella ricerca, non corrisponde a quello della
                //TEST
                //var squadDetailsResponse = client.GetSquadDetailsAsync(squad.Id).GetAwaiter().GetResult();
                //foreach (var squadPlayer in squadDetailsResponse.Players)
                //{
                //    Console.WriteLine($"{squadPlayer.ItemData.FirstName} {squadPlayer.ItemData.LastName}");
                //}

                Console.WriteLine();
            }


            Console.ReadKey();
        }
示例#5
0
 public static async Task ConnectionAsync(FutClient client)
 {
     var loginDetails = new LoginDetails("", "", "", Platform.XboxOne, AppVersion.WebApp);
     ITwoFactorCodeProvider provider = new FutAuth();
     var loginResponse = await client.LoginAsync(loginDetails, provider);
 }
示例#6
0
        private async void btnLogin_Click(object sender, EventArgs e)
        {
            if (tbUsername.Text == "" || tbPassword.Text == "" || tbSecret.Text == "")
            {
                MessageBox.Show("Please fill all fields");
                return;
            }

            Platform platform = Platform.Pc;
            var      user     = tbUsername.Text;
            var      password = tbPassword.Text;
            var      sAnswer  = tbSecret.Text;

            if (File.Exists("cookies\\" + user + "_cookie.dat"))
            {
                CookieContainer cookie = CookieUtil.ReadCookiesFromDisk("cookies\\" + user + "_cookie.dat");
                _client = new FutClient(cookie);
            }
            else
            {
                _client = new FutClient();
            }

            this.Enabled = false;

            switch (cbPlatform.SelectedIndex)
            {
            case 0:
                platform = Platform.Pc;
                break;

            case 1:
                platform = Platform.Ps3;
                break;

            case 2:
                platform = Platform.Ps4;
                break;

            case 3:
                platform = Platform.Xbox360;
                break;

            case 4:
                platform = Platform.XboxOne;
                break;
            }

            var loginDetails = new LoginDetails(user, password, sAnswer, platform);
            ITwoFactorCodeProvider provider = new ImapTwoFactorCodeProvider();

            try
            {
                await _client.LoginAsync(loginDetails, provider);

                if (!File.Exists("cookies\\" + user + "_cookie.dat"))
                {
                    var cookiecontainer = _client.RequestFactories.CookieContainer;
                    CookieUtil.WriteCookiesToDisk("cookies\\" + user + "_cookie.dat", cookiecontainer);
                }
                var frm = new FormMain(_client, new[] { user, password, sAnswer, cbPlatform.SelectedIndex.ToString() });
                frm.Show();
                Hide();
            }
            catch (FutException ex)
            {
                MessageBox.Show("Login Failed");
                WriteLog.DoWrite("Login Failed: " + ex.InnerException.Message);
                _client = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
                WriteLog.DoWrite("Login Error: " + ex.InnerException.Message);
                _client = null;
            }
            finally
            {
                this.Enabled = true;
            }
        }
示例#7
0
        private async void SearchMarket()
        {
            if (_i >= mgTable.Rows.Count - 1) //check if i needs a reset
            {
                _i = 0;
            }

            try
            {
                var searchParameters = new PlayerSearchParameters
                {
                    Page       = 1,
                    MaxBuy     = uint.Parse(mgTable[2, _i].Value.ToString()),
                    ResourceId = uint.Parse(mgTable[8, _i].Value.ToString())
                };

                // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
                uint.Parse(mgTable[3, _i].Value.ToString());     //check sell for null

                var searchResponse = await _client.SearchAsync(searchParameters);

                if (_debug)
                {
                    tbLog.SelectionColor = Color.Blue;
                    tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " Search for Player " +
                                           mgTable[1, _i].Value + Environment.NewLine;
                    tbLog.SelectionColor = Color.Blue;
                    tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " " +
                                           searchResponse.AuctionInfo.Count + " Auctions found" +
                                           Environment.NewLine;
                }
                foreach (var auctionInfo in searchResponse.AuctionInfo)
                {
                    // Handle auction data
                    if (searchResponse.AuctionInfo.Count < _maxplayersonrequest)     //check for pricefix
                    {
                        await _client.PlaceBidAsync(auctionInfo, auctionInfo.BuyNowPrice);

                        //Buyout Item
                        await _client.SendItemToTradePileAsync(auctionInfo.ItemData);

                        //send Item to Tradepile
                        int counter = int.Parse(mgTable[4, _i].Value.ToString());
                        counter++;
                        mgTable[4, _i].Value = counter.ToString();
                        tbLog.SelectionColor = Color.Black;
                        tbLog.SelectedText   = DateTime.Now.ToLongTimeString() +
                                               " Buyout for Player " +
                                               mgTable[1, _i].Value + Environment.NewLine;
                        WriteLog.DoWrite("Buyout for Player " + mgTable[1, _i].Value);
                        if (_playSound)
                        {
                            SystemSounds.Exclamation.Play();
                        }
                        GetCredits();
                    }
                }
            }

            catch (NotEnoughCreditException)
            {
                WriteLog.DoWrite("Not enough credits");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " Not enough credits " +
                                       Environment.NewLine;
            }
            catch (CaptchaTriggeredException) //Captcha Triggered!
            {
                WriteLog.DoWrite("Captach triggered");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " Captcha triggered " +
                                       Environment.NewLine;
                Stopbot();
            }
            catch (ExpiredSessionException) //Session Expired
            {
                WriteLog.DoWrite("Session Expired");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " Session Expired " +
                                       Environment.NewLine;
                Stopbot();
                using (var x = new FormRelog(_account))
                {
                    x.ShowDialog();
                    this._client = x.Client;
                }
                Startbot();
            }
            catch (FormatException)
            {
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " Entry " + _i +
                                       " has an invalid Format or is null" +
                                       Environment.NewLine;
                Stopbot();
            }
            catch (NullReferenceException)
            {
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() + " Entry " + _i +
                                       " has an invalid Format or is null" +
                                       Environment.NewLine;
                Stopbot();
            }
            catch (Exception ex)
            {
                WriteLog.DoWrite("Error on search: " + ex);
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() +
                                       " Error on search- Please be sure that your transfermarket is not locked" +
                                       Environment.NewLine;
            }
            finally
            {
                _i++;
            }
        }