コード例 #1
0
        private void btnSetLocation_Click(object sender, EventArgs e)
        {
            try
            {
                // Persist the Position
                lat = double.Parse(boxLat.Text);
                lng = double.Parse(boxLng.Text);

                // User Settings
                UserSettings.Default.DefaultLatitude  = lat;
                UserSettings.Default.DefaultLongitude = lng;
                UserSettings.Default.Save();

                // Confirm Position Selection
                setPos = true;

                // Close this Window
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Data on Lat/Lng", "PoGo Bot");
                ErrorReportCreator.Create("SetLocationErrorLog", "Error while picking the location", ex);
            }
        }
コード例 #2
0
        private async void StartBottingSession()
        {
            // Setup the Timer
            _sessionTimer.Interval = 5000;
            _sessionTimer.Start();
            _sessionStartTime = DateTime.Now;

            // Loop Until we Manually Stop
            while (_isFarmingActive)
            {
                try
                {
                    // Start Farming Pokestops/Pokemons.
                    await ExecuteFarmingPokestopsAndPokemons();

                    // Only Auto-Evolve when Continuous.
                    if (_isFarmingActive && GUISettings.Default.autoEvolve)
                    {
                        // Evolve Pokemons.
                        await EvolveAllPokemonWithEnoughCandy();
                    }

                    // Only Transfer when Continuous.
                    if (_isFarmingActive && GUISettings.Default.autoTransfer)
                    {
                        // Transfer Duplicates.
                        await TransferDuplicatePokemon();
                    }
                }
                catch (InvalidResponseException)
                {
                    // Need to Re-Authenticate
                    await reauthenticateWithServer();

                    // Disable Buttons
                    disableButtonsDuringFarming();
                }
                catch (Exception ex)
                {
                    // Write Error to Console
                    Logger.Write($"Error: {ex.Message}");

                    // Create Log Report
                    ErrorReportCreator.Create("Фарм", "General Exception while Farming", ex);

                    // Need to Re-Authenticate (In Testing)
                    await reauthenticateWithServer();

                    // Disable Buttons
                    disableButtonsDuringFarming();
                }
            }
        }
コード例 #3
0
 private async void PokemonForm_Load(object sender, EventArgs e)
 {
     try
     {
         resetLoadProgress();
         await Execute();
     }
     catch (Exception ex)
     {
         ErrorReportCreator.Create("Список покемонов", "Не могу открыть список покемонов", ex);
     }
 }
コード例 #4
0
 private async void PokemonForm_Load(object sender, EventArgs e)
 {
     try
     {
         resetLoadProgress();
         await Execute();
     }
     catch (Exception ex)
     {
         ErrorReportCreator.Create("MyPokemonList", "Unable to Open My Pokemon List", ex);
     }
 }
コード例 #5
0
        private async Task RecycleItems()
        {
            try
            {
                // Clear Grid
                dGrid.Rows.Clear();

                // Prepare Grid
                dGrid.ColumnCount     = 3;
                dGrid.Columns[0].Name = "Действие";
                dGrid.Columns[1].Name = "Счетчик";
                dGrid.Columns[2].Name = "Вещь";

                // Logging
                Logger.Write("Отсортировка для получения свободных слотов");

                var items = await _inventory.GetItemsToRecycle(_settings);

                foreach (var item in items)
                {
                    var transfer = await _client.RecycleItem((ItemId)item.Item_, item.Count);

                    Logger.Write($"Отсортированно {item.Count}x {(ItemId)item.Item_}", LogLevel.Info);

                    // GUI Experience
                    dGrid.Rows.Insert(0, "Отсортированно", item.Count, ((ItemId)item.Item_).ToString());

                    await Task.Delay(500);
                }

                await GetCurrentPlayerInformation();

                // Logging
                Logger.Write("Все отсортированно.");
            }
            catch (InvalidResponseException)
            {
                await reauthenticateWithServer();
                await RecycleItems();
            }
            catch (Exception ex)
            {
                // Create Error Log
                ErrorReportCreator.Create("Ошибка", "Ошибка при отсортировке", ex);

                Logger.Write($"Ошибка: {ex.Message}");
                Logger.Write("Не могу выкинуть вещи.");
            }
        }
コード例 #6
0
        private async Task RecycleItems()
        {
            try
            {
                // Clear Grid
                dGrid.Rows.Clear();

                // Prepare Grid
                dGrid.ColumnCount     = 3;
                dGrid.Columns[0].Name = "Action";
                dGrid.Columns[1].Name = "Count";
                dGrid.Columns[2].Name = "Item";

                // Logging
                Logger.Write("Recycling Items to Free Space");

                var items = await _inventory.GetItemsToRecycle(_settings);

                foreach (var item in items)
                {
                    var transfer = await _client.RecycleItem((ItemId)item.Item_, item.Count);

                    Logger.Write($"Recycled {item.Count}x {(ItemId)item.Item_}", LogLevel.Info);

                    // GUI Experience
                    dGrid.Rows.Insert(0, "Recycled", item.Count, ((ItemId)item.Item_).ToString());

                    await Task.Delay(500);
                }

                await GetCurrentPlayerInformation();

                // Logging
                Logger.Write("Recycling Complete.");
            }
            catch (InvalidResponseException)
            {
                await reauthenticateWithServer();
                await RecycleItems();
            }
            catch (Exception ex)
            {
                // Create Error Log
                ErrorReportCreator.Create("SilentRecycleError", "Problem during Silent Recycling", ex);

                Logger.Write($"Error Details: {ex.Message}");
                Logger.Write("Unable to Complete Items Recycling.");
            }
        }
コード例 #7
0
        private async Task LoginPtc(string username, string password)
        {
            try
            {
                // Login Method
                _loginMethod = AuthType.Ptc;
                _username    = username;
                _password    = password;

                // Creating the Settings
                Logger.Write("Настройка.");
                UserSettings.Default.AuthType    = AuthType.Ptc.ToString();
                UserSettings.Default.PtcUsername = username;
                UserSettings.Default.PtcPassword = password;
                _settings = new Settings();

                // Begin Login
                Logger.Write("Попытка соединения через PTC...");
                Client client = new Client(_settings);
                await client.DoPtcLogin(_settings.PtcUsername, _settings.PtcPassword);

                await client.SetServer();

                // Server Ready
                Logger.Write("Соединение установлено!");
                _client = client;

                Logger.Write("Получаю информацию об аккаунте!");
                _inventory = new Inventory(client);
                _profile   = await client.GetProfile();

                EnableButtons();
                _loginSuccess = true;
            }
            catch (Exception ex)
            {
                // Error Logging
                ErrorReportCreator.Create("PTCLoginError", "Невозможно установить соединение.", ex);

                Logger.Write("Невозможно установить соединение.");
                MessageBox.Show(@"Невозможно установить соединение.", @"Ошибка");
                Application.Exit();
            }
        }
コード例 #8
0
        private async Task LoginPtc(string username, string password)
        {
            try
            {
                // Login Method
                _loginMethod = AuthType.Ptc;
                _username    = username;
                _password    = password;

                // Creating the Settings
                Logger.Write("Adjusting the Settings.");
                UserSettings.Default.AuthType    = AuthType.Ptc.ToString();
                UserSettings.Default.PtcUsername = username;
                UserSettings.Default.PtcPassword = password;
                _settings = new Settings();

                // Begin Login
                Logger.Write("Trying to Login with PTC Credentials...");
                Client client = new Client(_settings);
                await client.DoPtcLogin(_settings.PtcUsername, _settings.PtcPassword);

                await client.SetServer();

                // Server Ready
                Logger.Write("Connected! Server is Ready.");
                _client = client;

                Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
                _inventory = new Inventory(client);
                _profile   = await client.GetProfile();

                EnableButtons();
                _loginSuccess = true;
            }
            catch (Exception ex)
            {
                // Error Logging
                ErrorReportCreator.Create("PTCLoginError", "Unable to Login with PTC", ex);

                Logger.Write("Unable to Connect using the PTC Credentials.");
                MessageBox.Show(@"Unable to Authenticate with Login Server.", @"Login Problem");
                Application.Exit();
            }
        }
コード例 #9
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // Setup Console
                console = new ConsoleForm();
                console.StartPosition = FormStartPosition.Manual;
                console.Location      = new System.Drawing.Point((Screen.PrimaryScreen.Bounds.Width / 2) - 530, (Screen.PrimaryScreen.Bounds.Height / 2) + 310);

                // Start Loading
                StartLogger();
                CleanUp();

                // Begin Process
                if (!await DisplayLoginWindow())
                {
                    throw new LoginNotSelectedException("Невозможно залогиниться");
                }

                DisplayPositionSelector();
                await GetStorageSizes();
                await GetCurrentPlayerInformation();
                await PreflightCheck();

                // Starts the Timer for the Silent Recycle
                _recycleItemTimer = new System.Timers.Timer(5 * 60 * 1000); // 5 Minute timer
                _recycleItemTimer.Start();
                _recycleItemTimer.Elapsed += _recycleItemTimer_Elapsed;
                StartAppUsageReporting();
            }
            catch (LoginNotSelectedException ex)
            {
                MessageBox.Show(ex.Message, "PokemonGO БОТ");
                Application.Exit();
            }
            catch (Exception ex)
            {
                ErrorReportCreator.Create("Ошибка", "невохможно загрузить бота", ex);
                MessageBox.Show("Невохможно загрузить бота.", "PokemonGo Бот");
                Application.Exit();
            }
        }
コード例 #10
0
        private void DisplayPositionSelector()
        {
            // Display Position Selector
            LocationSelector locationSelect = new LocationSelector();

            locationSelect.ShowDialog();

            // Check if Position was Selected
            try
            {
                if (!locationSelect.setPos)
                {
                    throw new ArgumentException();
                }

                // Persisting the Initial Position
                _client.SaveLatLng(locationSelect.lat, locationSelect.lng);
                _client.SetCoordinates(locationSelect.lat, locationSelect.lng, UserSettings.Default.DefaultAltitude);
            }
            catch (Exception ex)
            {
                // Write a Detailed Log Report
                ErrorReportCreator.Create("Выбор локации", "Невозможно выбрать локацию", ex);

                MessageBox.Show(@"Обозначьте правильную стартовую локацию.", @"Проверка безопасности");
                MessageBox.Show(@"Чтобы избежать бана, программа завершает свою работу.", @"Проверка безопасности");
                Application.Exit();
            }

            // Display Starting Location
            Logger.Write($"Стартовая точка Lat(Широта): {UserSettings.Default.DefaultLatitude} Lng(Долгота): {UserSettings.Default.DefaultLongitude}");

            // Close the Location Window
            locationSelect.Close();

            // Setup MiniMap
            SetupLocationMap();
        }
コード例 #11
0
        private void DisplayPositionSelector()
        {
            // Display Position Selector
            LocationSelector locationSelect = new LocationSelector();

            locationSelect.ShowDialog();

            // Check if Position was Selected
            try
            {
                if (!locationSelect.setPos)
                {
                    throw new ArgumentException();
                }

                // Persisting the Initial Position
                _client.SaveLatLng(locationSelect.lat, locationSelect.lng);
                _client.SetCoordinates(locationSelect.lat, locationSelect.lng, UserSettings.Default.DefaultAltitude);
            }
            catch (Exception ex)
            {
                // Write a Detailed Log Report
                ErrorReportCreator.Create("SelectLocation", "Unable To Select Location", ex);

                MessageBox.Show(@"You need to declare a valid starting location.", @"Safety Check");
                MessageBox.Show(@"To protect your account of a possible soft ban, the software will close.", @"Safety Check");
                Application.Exit();
            }

            // Display Starting Location
            Logger.Write($"Starting in Location Lat: {UserSettings.Default.DefaultLatitude} Lng: {UserSettings.Default.DefaultLongitude}");

            // Close the Location Window
            locationSelect.Close();

            // Setup MiniMap
            SetupLocationMap();
        }
コード例 #12
0
        private async Task ExecuteFarmingPokestopsAndPokemons()
        {
            var mapObjects = await _client.GetMapObjects();

            var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime());

            var fortDatas = pokeStops as IList <FortData> ?? pokeStops.ToList();

            _pokestopsCount = fortDatas.Count <FortData>();
            int count = 1;

            foreach (var pokeStop in fortDatas)
            {
                // Use Teleporting if No Human Walking Enabled
                if (!GUISettings.Default.humanWalkingEnabled)
                {
                    var update = await _client.UpdatePlayerLocation(pokeStop.Latitude, pokeStop.Longitude, _settings.DefaultAltitude); // Redundant?

                    UpdateMap(pokeStop.Latitude, pokeStop.Longitude);
                }
                else
                {
                    HumanWalking  human          = new HumanWalking(_client);
                    GeoCoordinate targetLocation = new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude);
                    human.assignMapToUpdate(MainMap);
                    await human.Walk(targetLocation, GUISettings.Default.humanWalkingSpeed, ExecuteCatchAllNearbyPokemons);
                }

                var fortInfo = await _client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                boxPokestopName.Text  = fortInfo.Name;
                boxPokestopInit.Text  = count.ToString();
                boxPokestopCount.Text = _pokestopsCount.ToString();
                count++;

                var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                Logger.Write($"Лут -> Гемы: { fortSearch.GemsAwarded}, Яйца: {fortSearch.PokemonDataEgg} Вещи: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}");
                Logger.Write("Получено " + fortSearch.ExperienceAwarded + " XP.");

                // Experience Counter
                _totalExperience += fortSearch.ExperienceAwarded;

                await GetCurrentPlayerInformation();

                Logger.Write("Attempting to Capture Nearby Pokemons.");

                try
                {
                    await ExecuteCatchAllNearbyPokemons();
                }
                catch (Exception ex)
                {
                    Logger.Write("Ошибка при поимки покемона.");
                    ErrorReportCreator.Create("CatchingNearbyPokemonError", "Не могу поймать покемона.", ex);
                }

                if (!_isFarmingActive)
                {
                    Logger.Write("Прекращаю фармить покемонов.");
                    return;
                }

                Logger.Write("Ожидание.");
                await Task.Delay(GUISettings.Default.pokestopDelay * 1000);
            }
        }
コード例 #13
0
        private async Task LoginGoogle(string username, string password)
        {
            try
            {
                // Login Method
                _loginMethod = AuthType.Google;
                _username    = username;
                _password    = password;

                // Creating the Settings
                Logger.Write("Настрока.");
                UserSettings.Default.AuthType = AuthType.Google.ToString();
                _settings = new Settings();

                // Begin Login
                Logger.Write("Попытка входа через Google...");
                Client client = new Client(_settings);
                client.DoGoogleLogin(username, password);
                await client.SetServer();

                // Server Ready
                Logger.Write("Соединение установленно!");
                _client = client;

                Logger.Write("Получение данных о профиле...");
                _inventory = new Inventory(client);
                _profile   = await client.GetProfile();

                EnableButtons();
                _loginSuccess = true;
            }
            catch (GoogleException ex)
            {
                if (ex.Message.Contains("Нужен браузер"))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Видимо у вас двухэтапная аунтификация.");
                    sb.AppendLine("Вам необходимо создать пароль для приложения.");
                    sb.AppendLine();
                    sb.AppendLine("Перейдите по данной ссылке: https://security.google.com/settings/security/apppasswords");
                    sb.AppendLine("В 'Выбрать приложение' выберите  'Другие' и 'Мои' выбирете 'Компьютер виндовс'.");
                    sb.AppendLine();
                    sb.AppendLine("Это сгенерирует вам пароль для приложения.");
                    MessageBox.Show(sb.ToString(), "Google ДвуЭтапнаяАунтификация");
                    Application.Exit();
                }

                if (ex.Message.Contains("Невенрные данные"))
                {
                    MessageBox.Show("Ваши данные неверны.", "Вход через Google");
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                // Error Logging
                ErrorReportCreator.Create("GoogleLoginError", "Невозможно установить содинение", ex);

                Logger.Write("Невозможно установить соединение.");
                MessageBox.Show(@"Невозможно установить соединение.", @"Ошибка");
                Application.Exit();
            }
        }
コード例 #14
0
        private async Task LoginGoogle(string username, string password)
        {
            try
            {
                // Login Method
                _loginMethod = AuthType.Google;
                _username    = username;
                _password    = password;

                // Creating the Settings
                Logger.Write("Adjusting the Settings.");
                UserSettings.Default.AuthType = AuthType.Google.ToString();
                _settings = new Settings();

                // Begin Login
                Logger.Write("Trying to Login with Google Token...");
                Client client = new Client(_settings);
                client.DoGoogleLogin(username, password);
                await client.SetServer();

                // Server Ready
                Logger.Write("Connected! Server is Ready.");
                _client = client;

                Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
                _inventory = new Inventory(client);
                _profile   = await client.GetProfile();

                EnableButtons();
                _loginSuccess = true;
            }
            catch (GoogleException ex)
            {
                if (ex.Message.Contains("NeedsBrowser"))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("It seems you have Google 2 Factor Authentication enabled.");
                    sb.AppendLine("In order to enable this bot to access your Google Account you need to create an App Password and use that one instead of your Google Password.");
                    sb.AppendLine();
                    sb.AppendLine("Please go to: https://security.google.com/settings/security/apppasswords");
                    sb.AppendLine("In 'Select App' select 'Other' and 'on my' select 'Windows Computer'.");
                    sb.AppendLine();
                    sb.AppendLine("This will generate a random password use that password login to the bot.");
                    MessageBox.Show(sb.ToString(), "Google 2 Factor Authentication");
                    Application.Exit();
                }

                if (ex.Message.Contains("BadAuth"))
                {
                    MessageBox.Show("Your Google Credentials are incorrect.", "Google Login");
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                // Error Logging
                ErrorReportCreator.Create("GoogleLoginError", "Unable to Login with Google", ex);

                Logger.Write("Unable to Connect using the Google Token.");
                MessageBox.Show(@"Unable to Authenticate with Login Server.", @"Login Problem");
                Application.Exit();
            }
        }