private async void Execute() { client = new Client(ClientSettings); this.locationManager = new LocationManager(client, Speed); try { switch (ClientSettings.AuthType) { case AuthType.Ptc: ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club"); await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword); break; case AuthType.Google: ColoredConsoleWrite(Color.Green, "Login Type: Google"); if (ClientSettings.GoogleRefreshToken == "") ColoredConsoleWrite(Color.Green, "Now opening www.Google.com/device and copying the 8 digit code to your clipboard"); await client.DoGoogleLogin(); break; } await client.SetServer(); var profile = await client.GetProfile(); var settings = await client.GetSettings(); var mapObjects = await client.GetMapObjects(); var inventory = await client.GetInventory(); var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon) .Where(p => p != null && p?.PokemonId > 0); ConsoleLevelTitle(profile.Profile.Username, client); // Write the players ingame details ColoredConsoleWrite(Color.Yellow, "----------------------------"); if (ClientSettings.AuthType == AuthType.Ptc) { ColoredConsoleWrite(Color.Cyan, "Account: " + ClientSettings.PtcUsername); ColoredConsoleWrite(Color.Cyan, "Password: "******"\n"); } ColoredConsoleWrite(Color.DarkGray, "Name: " + profile.Profile.Username); ColoredConsoleWrite(Color.DarkGray, "Team: " + profile.Profile.Team); if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have. ColoredConsoleWrite(Color.DarkGray, "Pokecoins: " + profile.Profile.Currency.ToArray()[0].Amount); ColoredConsoleWrite(Color.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount + "\n"); ColoredConsoleWrite(Color.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude); ColoredConsoleWrite(Color.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude); try { ColoredConsoleWrite(Color.DarkGray, "Country: " + CallAPI("country", ClientSettings.DefaultLatitude, ClientSettings.DefaultLongitude)); ColoredConsoleWrite(Color.DarkGray, "Area: " + CallAPI("place", ClientSettings.DefaultLatitude, ClientSettings.DefaultLongitude)); } catch (Exception) { ColoredConsoleWrite(Color.DarkGray, "Unable to get Country/Place"); } ColoredConsoleWrite(Color.Yellow, "----------------------------"); // I believe a switch is more efficient and easier to read. switch (ClientSettings.TransferType) { case "Leave Strongest": await TransferAllButStrongestUnwantedPokemon(client); break; case "All": await TransferAllGivenPokemons(client, pokemons); break; case "Duplicate": await TransferDuplicatePokemon(client); break; case "IV Duplicate": await TransferDuplicateIVPokemon(client); break; case "CP": await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold); break; case "IV": await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold); break; default: ColoredConsoleWrite(Color.DarkGray, "Transfering pokemon disabled"); break; } if (ClientSettings.EvolveAllGivenPokemons) await EvolveAllGivenPokemons(client, pokemons); if (ClientSettings.Recycler) client.RecycleItems(client); await Task.Delay(5000); PrintLevel(client); await ExecuteFarmingPokestopsAndPokemons(client); ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds."); await Task.Delay(10000); CheckVersion(); Execute(); } catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); Execute(); } catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); Execute(); } catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); Execute(); } catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); Execute(); } catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); Execute(); } catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); Execute(); } }
private async void Execute() { client = new Client(ClientSettings); this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed); try { switch (ClientSettings.AuthType) { case AuthType.Ptc: ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club"); break; case AuthType.Google: ColoredConsoleWrite(Color.Green, "Login Type: Google"); break; } await client.Login(); await client.SetServer(); var profile = await client.GetProfile(); var settings = await client.GetSettings(); var mapObjects = await client.GetMapObjects(); var inventory = await client.GetInventory(); var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon) .Where(p => p != null && p?.PokemonId > 0); updateUserStatusBar(client); // Write the players ingame details ColoredConsoleWrite(Color.Yellow, "----------------------------"); /*// dont actually want to display info but keeping here incase people want to \O_O/ * if (ClientSettings.AuthType == AuthType.Ptc) { ColoredConsoleWrite(Color.Cyan, "Account: " + ClientSettings.PtcUsername); ColoredConsoleWrite(Color.Cyan, "Password: "******"\n"); } else { ColoredConsoleWrite(Color.Cyan, "Email: " + ClientSettings.Email); ColoredConsoleWrite(Color.Cyan, "Password: "******"\n"); }*/ string lat2 = System.Convert.ToString(ClientSettings.DefaultLatitude); string longit2 = System.Convert.ToString(ClientSettings.DefaultLongitude); ColoredConsoleWrite(Color.DarkGray, "Name: " + profile.Profile.Username); ColoredConsoleWrite(Color.DarkGray, "Team: " + profile.Profile.Team); if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have. ColoredConsoleWrite(Color.DarkGray, "Pokecoins: " + profile.Profile.Currency.ToArray()[0].Amount); ColoredConsoleWrite(Color.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount + "\n"); ColoredConsoleWrite(Color.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude); ColoredConsoleWrite(Color.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude); try { ColoredConsoleWrite(Color.DarkGray, "Country: " + CallAPI("country", lat2.Replace(',', '.'), longit2.Replace(',', '.'))); ColoredConsoleWrite(Color.DarkGray, "Area: " + CallAPI("place", lat2.Replace(',', '.'), longit2.Replace(',', '.'))); } catch (Exception) { ColoredConsoleWrite(Color.DarkGray, "Unable to get Country/Place"); } ColoredConsoleWrite(Color.Yellow, "----------------------------"); // I believe a switch is more efficient and easier to read. switch (ClientSettings.TransferType) { case "Leave Strongest": await TransferAllButStrongestUnwantedPokemon(client); break; case "All": await TransferAllGivenPokemons(client, pokemons); break; case "CP Duplicate": await TransferDuplicatePokemon(client); break; case "IV Duplicate": await TransferDuplicateIVPokemon(client); break; case "CP/IV Duplicate": await TransferDuplicateCPIVPokemon(client); break; case "CP": await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold); break; case "IV": await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold); break; default: ColoredConsoleWrite(Color.DarkGray, "Transfering pokemon disabled"); break; } if (ClientSettings.EvolveAllGivenPokemons) await EvolveAllGivenPokemons(client, pokemons); if (ClientSettings.Recycler) client.RecycleItems(client); await Task.Delay(5000); PrintLevel(client); await ExecuteFarmingPokestopsAndPokemons(client); while (ForceUnbanning) await Task.Delay(25); // await ForceUnban(client); if (!Stopping) { ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds."); await Task.Delay(10000); Execute(); } else { confirmBotStopped(); } } catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); } catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting");} catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); } catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); } catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); } catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString());} finally { if (!Stopping) { Execute(); } else { confirmBotStopped(); } } }
private async void Execute() { client = new Client(ClientSettings); this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed); try { switch (ClientSettings.AuthType) { case AuthType.Ptc: ColoredConsoleWrite(Color.Green, Properties.Strings.login_type_PTC); break; case AuthType.Google: ColoredConsoleWrite(Color.Green, Properties.Strings.login_type_Google); break; } await client.Login(); await client.SetServer(); var profile = await client.GetProfile(); var settings = await client.GetSettings(); var mapObjects = await client.GetMapObjects(); var inventory = await client.GetInventory(); var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon) .Where(p => p != null && p?.PokemonId > 0); updateUserStatusBar(client); // Write the players ingame details ColoredConsoleWrite(Color.Yellow, "----------------------------"); /*// dont actually want to display info but keeping here incase people want to \O_O/ * if (ClientSettings.AuthType == AuthType.Ptc) { ColoredConsoleWrite(Color.Cyan, string.Format(Properties.Strings.account, ClientSettings.PtcUsername)); ColoredConsoleWrite(Color.Cyan, string.Format(Properties.Strings.password, ClientSettings.PtcPassword)); } else { ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.name, profile.Profile.Username)); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.team, profile.Profile.Team)); }*/ string lat2 = System.Convert.ToString(ClientSettings.DefaultLatitude); string longit2 = System.Convert.ToString(ClientSettings.DefaultLongitude); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.name, profile.Profile.Username)); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.team, profile.Profile.Team)); if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have. ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.pokecoin, profile.Profile.Currency.ToArray()[0].Amount)); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.stardust, profile.Profile.Currency.ToArray()[1].Amount)); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.latitude, ClientSettings.DefaultLatitude)); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.longitude, ClientSettings.DefaultLongitude)); try { ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.country, CallAPI("country", lat2.Replace(',', '.'), longit2.Replace(',', '.')))); ColoredConsoleWrite(Color.DarkGray, string.Format(Properties.Strings.area, CallAPI("place", lat2.Replace(',', '.'), longit2.Replace(',', '.')))); } catch (Exception) { ColoredConsoleWrite(Color.DarkGray, Properties.Strings.error_country); } ColoredConsoleWrite(Color.Yellow, "----------------------------"); //Choosing if else, because switch case handle only constant values if(ClientSettings.TransferType == Properties.Strings.TransferType_Strongest) await TransferAllButStrongestUnwantedPokemon(client); else if(ClientSettings.TransferType == Properties.Strings.TransferType_All) await TransferAllGivenPokemons(client, pokemons); else if(ClientSettings.TransferType == Properties.Strings.TransferType_Duplicate) await TransferDuplicatePokemon(client); else if(ClientSettings.TransferType == Properties.Strings.TransferType_IV_Duplicate) await TransferDuplicateIVPokemon(client); else if(ClientSettings.TransferType == Properties.Strings.TransferType_CP) await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold); else if(ClientSettings.TransferType == Properties.Strings.TransferType_IV) await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold); else ColoredConsoleWrite(Color.DarkGray, Properties.Strings.transfering_disabled); if (ClientSettings.EvolveAllGivenPokemons) await EvolveAllGivenPokemons(client, pokemons); if (ClientSettings.Recycler) client.RecycleItems(client); await Task.Delay(5000); PrintLevel(client); await ExecuteFarmingPokestopsAndPokemons(client); while (ForceUnbanning) await Task.Delay(25); // await ForceUnban(client); if (!Stopping) { ColoredConsoleWrite(Color.Red, Properties.Strings.no_location); await Task.Delay(10000); CheckVersion(); Execute(); } else { ConsoleClear(); pokestopsOverlay.Routes.Clear(); pokestopsOverlay.Markers.Clear(); ColoredConsoleWrite(Color.Red, Properties.Strings.bot_stop); startStopBotToolStripMenuItem.Text = Properties.Strings.start; Stopping = false; bot_started = false; } } catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); if (!Stopping) { client = null; Execute(); } } }
private async void Execute() { client = new Client(ClientSettings); this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed); try { switch (ClientSettings.AuthType) { case AuthType.Ptc: ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club"); await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword); break; case AuthType.Google: ColoredConsoleWrite(Color.Green, "Login Type: Google"); await client.DoGoogleLogin(ClientSettings.Email, ClientSettings.Password); break; } await client.SetServer(); var profile = await client.GetProfile(); var settings = await client.GetSettings(); connected = true; ConsoleLevelTitle(profile.Profile.Username, client); // Write the players ingame details WriteConnectLogs(profile); // I believe a switch is more efficient and easier to read. client.stopRecycle = false; stopPrintLevel = false; if (ClientSettings.Recycler) recycle = client.RecycleItems(client); printLevel = PrintLevel(client); await EvolveAndTransfert(client); await ExecuteFarmingPokestopsAndPokemons(client); await UnbannedCheck(); } catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); if (!Stopping) await Restart(client); } catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); if (!Stopping) await Restart(client); } catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); if (!Stopping) await Restart(client); } catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); if (!Stopping) await Restart(client); } catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); if (!Stopping) await Restart(client); } catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); if (!Stopping) await Restart(client); } }
private async void Execute() { client = new Client(ClientSettings); this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed); try { switch (ClientSettings.AuthType) { case AuthType.Ptc: ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club"); await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword); break; case AuthType.Google: ColoredConsoleWrite(Color.Green, "Login Type: Google"); await client.DoGoogleLogin(ClientSettings.Email, ClientSettings.Password); break; } await client.SetServer(); var profile = await client.GetProfile(); var settings = await client.GetSettings(); var mapObjects = await client.GetMapObjects(); var inventory = await client.GetInventory(); var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon) .Where(p => p != null && p?.PokemonId > 0); ConsoleLevelTitle(profile.Profile.Username, client); // Write the players ingame details ColoredConsoleWrite(Color.Yellow, "----------------------------"); /*// dont actually want to display info but keeping here incase people want to \O_O/ * if (ClientSettings.AuthType == AuthType.Ptc) * { * ColoredConsoleWrite(Color.Cyan, "Account: " + ClientSettings.PtcUsername); * ColoredConsoleWrite(Color.Cyan, "Password: "******"\n"); * } * else * { * ColoredConsoleWrite(Color.Cyan, "Email: " + ClientSettings.Email); * ColoredConsoleWrite(Color.Cyan, "Password: "******"\n"); * }*/ ColoredConsoleWrite(Color.DarkGray, "Name: " + profile.Profile.Username); ColoredConsoleWrite(Color.DarkGray, "Team: " + profile.Profile.Team); if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have. { ColoredConsoleWrite(Color.DarkGray, "Pokecoins: " + profile.Profile.Currency.ToArray()[0].Amount); } ColoredConsoleWrite(Color.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount + "\n"); ColoredConsoleWrite(Color.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude); ColoredConsoleWrite(Color.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude); try { ColoredConsoleWrite(Color.DarkGray, "Country: " + CallAPI("country", ClientSettings.DefaultLatitude, ClientSettings.DefaultLongitude)); ColoredConsoleWrite(Color.DarkGray, "Area: " + CallAPI("place", ClientSettings.DefaultLatitude, ClientSettings.DefaultLongitude)); } catch (Exception) { ColoredConsoleWrite(Color.DarkGray, "Unable to get Country/Place"); } ColoredConsoleWrite(Color.Yellow, "----------------------------"); // I believe a switch is more efficient and easier to read. switch (ClientSettings.TransferType) { case "Leave Strongest": await TransferAllButStrongestUnwantedPokemon(client); break; case "All": await TransferAllGivenPokemons(client, pokemons); break; case "Duplicate": await TransferDuplicatePokemon(client); break; case "IV Duplicate": await TransferDuplicateIVPokemon(client); break; case "CP": await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold); break; case "IV": await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold); break; default: ColoredConsoleWrite(Color.DarkGray, "Transfering pokemon disabled"); break; } if (ClientSettings.EvolveAllGivenPokemons) { await EvolveAllGivenPokemons(client, pokemons); } if (ClientSettings.Recycler) { client.RecycleItems(client); } await Task.Delay(5000); PrintLevel(client); await ExecuteFarmingPokestopsAndPokemons(client); while (ForceUnbanning) { await Task.Delay(25); } // await ForceUnban(client); if (!Stopping) { ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds."); await Task.Delay(10000); CheckVersion(); Execute(); } else { ConsoleClear(); ColoredConsoleWrite(Color.Red, $"Bot successfully stopped."); startStopBotToolStripMenuItem.Text = "Start"; Stopping = false; bot_started = false; } } catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); if (!Stopping) { Execute(); } } catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); if (!Stopping) { Execute(); } } catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); if (!Stopping) { Execute(); } } catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); if (!Stopping) { Execute(); } } catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); if (!Stopping) { Execute(); } } catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); if (!Stopping) { Execute(); } } }