Merge pull request #314 from 1461748123/force-unban

Detective Squirrel [2016-07-28 06:25:48]
Merge pull request #314 from 1461748123/force-unban

Force unban
Filename
PokemonGo/RocketAPI/Console/App.config
PokemonGo/RocketAPI/Window/MainForm.Designer.cs
PokemonGo/RocketAPI/Window/MainForm.cs
diff --git a/PokemonGo/RocketAPI/Console/App.config b/PokemonGo/RocketAPI/Console/App.config
index d7cfe10..98a593f 100644
--- a/PokemonGo/RocketAPI/Console/App.config
+++ b/PokemonGo/RocketAPI/Console/App.config
@@ -12,12 +12,12 @@
     </assemblyBinding>
   </runtime>
   <appSettings>
-    <add key="AuthType" value="Ptc" /> <!--Google/Ptc-->
+    <add key="AuthType" value="Google" /> <!--Google/Ptc-->
     <add key="PtcUsername" value="username" /> <!--Username-->
     <add key="PtcPassword" value="pw" /> <!--Password-->
     <add key="GoogleRefreshToken" value="" />
-    <add key="DefaultLatitude" value="-36.842887" /> <!--Default Viaduct Harbour, Auckland, New Zealand-->
-    <add key="DefaultLongitude" value="174.766365" /> <!--Default Viaduct Harbour, Auckland, New Zealand-->
+    <add key="DefaultLatitude" value="45.030152" /> <!--Default Viaduct Harbour, Auckland, New Zealand-->
+    <add key="DefaultLongitude" value="-93.31931" /> <!--Default Viaduct Harbour, Auckland, New Zealand-->
     <add key="LevelOutput" value="levelup" /> <!--2 Modes: "time": Every XXX seconds and "levelup" every levelup-->
     <add key="LevelTimeInterval" value="1" /> <!--Pick 1 if levelup and time in seconds if "time"-->
     <add key="Recycler" value="true" /> <!--Recycler master switch-->
@@ -28,7 +28,7 @@
     <add key="TransferType" value="duplicate" /> <!--none/cp/iv/leaveStrongest/duplicate/all Whitelists/blackslists for each type is in Program.cs-->
     <add key="TransferCPThreshold" value="0" /> <!--transfer pokemon with CP less than this value if cp transfer type is selected. Whitelist in Program.cs-->
     <add key="TransferIVThreshold" value="80" /> <!--transfer pokemon with IV less than this value if iv transfer type is selected. Whitelist in Program.cs-->
-    <add key="EvolveAllGivenPokemons" value="false" />
+    <add key="EvolveAllGivenPokemons" value="true" />
     <add key="ClientSettingsProvider.ServiceUri" value="" />
   </appSettings>
   <system.web>
diff --git a/PokemonGo/RocketAPI/Window/MainForm.Designer.cs b/PokemonGo/RocketAPI/Window/MainForm.Designer.cs
index 2379d18..addeace 100644
--- a/PokemonGo/RocketAPI/Window/MainForm.Designer.cs
+++ b/PokemonGo/RocketAPI/Window/MainForm.Designer.cs
@@ -39,6 +39,7 @@
             this.useLuckyEggToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.showAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.showAllToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+            this.forceUnbanToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.statusStrip1.SuspendLayout();
             this.menuStrip1.SuspendLayout();
             this.SuspendLayout();
@@ -49,9 +50,9 @@
             this.logTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
             this.logTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.logTextBox.ForeColor = System.Drawing.Color.White;
-            this.logTextBox.Location = new System.Drawing.Point(0, 24);
+            this.logTextBox.Location = new System.Drawing.Point(0, 25);
             this.logTextBox.Name = "logTextBox";
-            this.logTextBox.Size = new System.Drawing.Size(905, 471);
+            this.logTextBox.Size = new System.Drawing.Size(905, 430);
             this.logTextBox.TabIndex = 0;
             this.logTextBox.Text = "";
             this.logTextBox.TextChanged += new System.EventHandler(this.logTextBox_TextChanged);
@@ -60,7 +61,7 @@
             //
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.statusLabel});
-            this.statusStrip1.Location = new System.Drawing.Point(0, 495);
+            this.statusStrip1.Location = new System.Drawing.Point(0, 455);
             this.statusStrip1.Name = "statusStrip1";
             this.statusStrip1.Size = new System.Drawing.Size(905, 22);
             this.statusStrip1.TabIndex = 1;
@@ -69,7 +70,7 @@
             // statusLabel
             //
             this.statusLabel.Name = "statusLabel";
-            this.statusLabel.Size = new System.Drawing.Size(39, 17);
+            this.statusLabel.Size = new System.Drawing.Size(43, 17);
             this.statusLabel.Text = "Status";
             //
             // menuStrip1
@@ -78,10 +79,11 @@
             this.startBotToolStripMenuItem,
             this.todoToolStripMenuItem,
             this.pokemonToolStripMenuItem2,
-            this.useLuckyEggToolStripMenuItem});
+            this.useLuckyEggToolStripMenuItem,
+            this.forceUnbanToolStripMenuItem});
             this.menuStrip1.Location = new System.Drawing.Point(0, 0);
             this.menuStrip1.Name = "menuStrip1";
-            this.menuStrip1.Size = new System.Drawing.Size(905, 24);
+            this.menuStrip1.Size = new System.Drawing.Size(905, 25);
             this.menuStrip1.TabIndex = 2;
             this.menuStrip1.Text = "menuStrip1";
             //
@@ -109,7 +111,7 @@
             // useLuckyEggToolStripMenuItem
             //
             this.useLuckyEggToolStripMenuItem.Name = "useLuckyEggToolStripMenuItem";
-            this.useLuckyEggToolStripMenuItem.Size = new System.Drawing.Size(95, 20);
+            this.useLuckyEggToolStripMenuItem.Size = new System.Drawing.Size(105, 21);
             this.useLuckyEggToolStripMenuItem.Text = "Use Lucky Egg";
             this.useLuckyEggToolStripMenuItem.Click += new System.EventHandler(this.useLuckyEggToolStripMenuItem_Click);
             //
@@ -123,11 +125,18 @@
             this.showAllToolStripMenuItem1.Name = "showAllToolStripMenuItem1";
             this.showAllToolStripMenuItem1.Size = new System.Drawing.Size(32, 19);
             //
+            // forceUnbanToolStripMenuItem
+            //
+            this.forceUnbanToolStripMenuItem.Name = "forceUnbanToolStripMenuItem";
+            this.forceUnbanToolStripMenuItem.Size = new System.Drawing.Size(94, 21);
+            this.forceUnbanToolStripMenuItem.Text = "Force Unban";
+            this.forceUnbanToolStripMenuItem.Click += new System.EventHandler(this.forceUnbanToolStripMenuItem_Click);
+            //
             // MainForm
             //
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(905, 517);
+            this.ClientSize = new System.Drawing.Size(905, 477);
             this.Controls.Add(this.logTextBox);
             this.Controls.Add(this.statusStrip1);
             this.Controls.Add(this.menuStrip1);
@@ -158,6 +167,7 @@
         private System.Windows.Forms.ToolStripMenuItem showAllToolStripMenuItem1;
         private System.Windows.Forms.ToolStripMenuItem pokemonToolStripMenuItem2;
         private System.Windows.Forms.ToolStripMenuItem useLuckyEggToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem forceUnbanToolStripMenuItem;
     }
 }

diff --git a/PokemonGo/RocketAPI/Window/MainForm.cs b/PokemonGo/RocketAPI/Window/MainForm.cs
index 6ddd4c3..6fb4b26 100644
--- a/PokemonGo/RocketAPI/Window/MainForm.cs
+++ b/PokemonGo/RocketAPI/Window/MainForm.cs
@@ -31,13 +31,16 @@ namespace PokemonGo.RocketAPI.Window

         private void MainForm_Load(object sender, EventArgs e)
         {
-
+
         }

         public static ISettings ClientSettings;
         private static int Currentlevel = -1;
         private static int TotalExperience = 0;
         private static int TotalPokemon = 0;
+        private static bool ForceUnbanning = false;
+        private static bool FarmingStops = false;
+        private static bool FarmingPokemons = false;
         private static DateTime TimeStarted = DateTime.Now;
         public static DateTime InitSessionDateTime = DateTime.Now;

@@ -192,7 +195,7 @@ namespace PokemonGo.RocketAPI.Window
                         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;
                 }
@@ -269,6 +272,11 @@ namespace PokemonGo.RocketAPI.Window
                 await Task.Delay(5000);
                 PrintLevel(client);
                 await ExecuteFarmingPokestopsAndPokemons(client);
+
+                while (ForceUnbanning)
+                    await Task.Delay(25);
+
+                // await ForceUnban(client);
                 ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds.");
                 await Task.Delay(10000);
                 CheckVersion();
@@ -327,6 +335,11 @@ namespace PokemonGo.RocketAPI.Window

             foreach (var pokemon in pokemons)
             {
+                if (ForceUnbanning)
+                    break;
+
+                FarmingPokemons = true;
+
                 await locationManager.update(pokemon.Latitude, pokemon.Longitude);
                 var encounterPokemonResponse = await client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);
                 var pokemonCP = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
@@ -391,6 +404,7 @@ namespace PokemonGo.RocketAPI.Window
                         break;
                 }

+                FarmingPokemons = false;
                 await Task.Delay(3000);
             }
         }
@@ -404,9 +418,15 @@ namespace PokemonGo.RocketAPI.Window
             }
             HashSet<FortData> pokeStopSet = new HashSet<FortData>(pokeStops);
             IEnumerable<FortData> nextPokeStopList = null;
-            ColoredConsoleWrite(Color.Cyan, $"Visiting {pokeStops.Count()} PokeStops");
+            if (!ForceUnbanning)
+                ColoredConsoleWrite(Color.Cyan, $"Visiting {pokeStops.Count()} PokeStops");
             foreach (var pokeStop in pokeStops)
             {
+                if (ForceUnbanning)
+                    break;
+
+                FarmingStops = true;
+
                 double pokeStopDistance = locationManager.getDistance(pokeStop.Latitude, pokeStop.Longitude);
                 await locationManager.update(pokeStop.Latitude, pokeStop.Longitude);
                 var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
@@ -428,6 +448,7 @@ namespace PokemonGo.RocketAPI.Window

                 if (fortSearch.ExperienceAwarded != 0)
                     TotalExperience += (fortSearch.ExperienceAwarded);
+
                 var pokeStopMapObjects = await client.GetMapObjects();

                 /* Gets all pokeStops near this pokeStop which are not in the set of pokeStops being currently
@@ -448,6 +469,7 @@ namespace PokemonGo.RocketAPI.Window
                 if (ClientSettings.CatchPokemon)
                     await ExecuteCatchAllNearbyPokemons(client);
             }
+            FarmingStops = false;
             if (nextPokeStopList != null)
             {
                 client.RecycleItems(client);
@@ -455,6 +477,67 @@ namespace PokemonGo.RocketAPI.Window
             }
         }

+        private async Task ForceUnban(Client client)
+        {
+            if (!ForceUnbanning)
+            {
+                ColoredConsoleWrite(Color.LightGreen, "Waiting for last farming action to be complete...");
+                ForceUnbanning = true;
+
+                while (FarmingStops || FarmingPokemons)
+                {
+                    await Task.Delay(25);
+                }
+
+                ColoredConsoleWrite(Color.LightGreen, "Starting force unban...");
+
+                var mapObjects = await client.GetMapObjects();
+                var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime());
+
+                await Task.Delay(10000);
+                bool done = false;
+
+                foreach (var pokeStop in pokeStops)
+                {
+
+                    double pokeStopDistance = locationManager.getDistance(pokeStop.Latitude, pokeStop.Longitude);
+                    await locationManager.update(pokeStop.Latitude, pokeStop.Longitude);
+                    var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
+
+                    if (fortInfo.Name != string.Empty)
+                    {
+                        ColoredConsoleWrite(Color.LightGreen, "Chosen PokeStop " + fortInfo.Name + " for force unban");
+                        for (int i = 1; i <= 50; i++)
+                        {
+                            var fortSearch = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
+                            if (fortSearch.ExperienceAwarded == 0)
+                            {
+                                ColoredConsoleWrite(Color.LightGreen, "Attempt: " + i);
+                            }
+                            else
+                            {
+                                ColoredConsoleWrite(Color.LightGreen, "Fuck yes, you are now unbanned! Total attempts: " + i);
+                                done = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if (!done)
+                        ColoredConsoleWrite(Color.LightGreen, "Force unban failed, please try again.");
+
+                    ForceUnbanning = false;
+                    break;
+                }
+            }
+            else
+            {
+                ColoredConsoleWrite(Color.Red, "A force unban attempt is in action... Please wait.");
+            }
+
+
+        }
+
         private string GetFriendlyItemsString(IEnumerable<FortSearchResponse.Types.ItemAward> items)
         {
             var enumerable = items as IList<FortSearchResponse.Types.ItemAward> ?? items.ToList();
@@ -886,7 +969,7 @@ namespace PokemonGo.RocketAPI.Window
             // todo: add player stats later
         }

-        private async void useLuckyEggToolStripMenuItem_Click(object sender ,EventArgs e)
+        private async void useLuckyEggToolStripMenuItem_Click(object sender, EventArgs e)
         {
             if (client != null)
             {
@@ -900,7 +983,7 @@ namespace PokemonGo.RocketAPI.Window
                         var useItemXpBoostRequest = await client.UseItemXpBoost(ItemId.ItemLuckyEgg);
                         ColoredConsoleWrite(Color.Green, $"Using a Lucky Egg, we have {LuckyEgg.Count} left.");
                         ColoredConsoleWrite(Color.Yellow, $"Lucky Egg Valid until: {DateTime.Now.AddMinutes(30).ToString()}");
-
+
                         var stripItem = sender as ToolStripMenuItem;
                         stripItem.Enabled = false;
                         await Task.Delay(30000);
@@ -922,6 +1005,25 @@ namespace PokemonGo.RocketAPI.Window
             }
         }

+        private async void forceUnbanToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            if (client != null)
+            {
+                if (ForceUnbanning)
+                {
+                    ColoredConsoleWrite(Color.Red, "A force unban attempt is in action... Please wait.");
+                }
+                else
+                {
+                    await ForceUnban(client);
+                }
+            }
+            else
+            {
+                ColoredConsoleWrite(Color.Red, "Please start the bot before trying to force unban");
+            }
+        }
+
         private void showAllToolStripMenuItem2_Click(object sender, EventArgs e)
         {

@@ -939,6 +1041,7 @@ namespace PokemonGo.RocketAPI.Window
             var pForm = new PokeUi();
             pForm.Show();

+
         }
     }
 }
You may download the files in Public Git.