Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Softban bypass FIX - with checks. #925

Merged
merged 8 commits into from
Jul 27, 2016
Merged
2 changes: 1 addition & 1 deletion PoGo.NecroBot.CLI/ConsoleEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void HandleEvent(FortUsedEvent evt, Context ctx)

public void HandleEvent(FortFailedEvent evt, Context ctx)
{
Logger.Write(ctx.Translations.GetTranslation(TranslationString.EventFortFailed, evt.Retry),
Logger.Write(ctx.Translations.GetTranslation(TranslationString.EventFortFailed, evt.Retry, evt.Max),
LogLevel.Pokestop, ConsoleColor.DarkRed);
}

Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Translations
new KeyValuePair<TranslationString, string>(TranslationString.EventFortUsed,
"XP: {0}, Gems: {1}, Items: {2}"),
new KeyValuePair<TranslationString, string>(TranslationString.EventFortFailed,
"Looting failed, possible softban. Retry: {0}/40"),
"Looting failed, possible softban. Unban in: {0}/{1}"),
new KeyValuePair<TranslationString, string>(TranslationString.EventFortTargeted, "{0} in ({1}m)"),
new KeyValuePair<TranslationString, string>(TranslationString.EventProfileLogin, "Playing as {0}"),
new KeyValuePair<TranslationString, string>(TranslationString.EventUsedLuckyEgg,
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/Event/FortFailedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public class FortFailedEvent : IEvent
{
public int Retry;
public int Max;
}
}
49 changes: 30 additions & 19 deletions PoGo.NecroBot.Logic/Tasks/FarmPokestopsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace PoGo.NecroBot.Logic.Tasks
public static class FarmPokestopsTask
{
public static int TimesZeroXPawarded;

public static async Task Execute(Context ctx, StateMachine machine)
{
var distanceFromStart = LocationUtils.CalculateDistanceInMeters(
Expand Down Expand Up @@ -90,14 +91,34 @@ await ctx.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeS
}

FortSearchResponse fortSearch;
var fortRetry = 0;
do
{
var fortRetry = 0; //Current check
var retryNumber = 40; //How many times it needs to check to clear softban
var zeroCheck = 5; //How many times it checks fort before it thinks it's softban
do {
fortSearch = await ctx.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
if (fortSearch.ExperienceAwarded == 0) TimesZeroXPawarded++;
if (fortSearch.ExperienceAwarded > 0 && TimesZeroXPawarded > 0) TimesZeroXPawarded = 0;
if (TimesZeroXPawarded <= 5)
if (fortSearch.ExperienceAwarded == 0)
{
TimesZeroXPawarded++;

if (TimesZeroXPawarded > zeroCheck)
{
if ((int)fortSearch.CooldownCompleteTimestampMs != 0)
{
break; // Check if successfully looted, if so program can continue as this was "false alarm".
}

fortRetry += 1;

machine.Fire(new FortFailedEvent
{
Retry = fortRetry,
Max = retryNumber - zeroCheck
});

Random random = new Random();
await Task.Delay(200 + random.Next(0, 200)); //Randomized pause
}
} else {
machine.Fire(new FortUsedEvent
{
Exp = fortSearch.ExperienceAwarded,
Expand All @@ -106,18 +127,8 @@ await ctx.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeS
});

break; //Continue with program as loot was succesfull.
} //If fort gave 0 experience, retry 40 times to clear softban.
fortRetry += 1;

machine.Fire(new FortFailedEvent
{
Retry = fortRetry
});

var random = new Random();
await Task.Delay(500 + random.Next(0, 200)); //Randomized pause
} while (fortRetry < 50);
//Stop trying if softban is cleaned earlier or if 40 times fort looting failed.
}
} while (fortRetry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

await Task.Delay(1000);
if (++stopsHit%5 == 0) //TODO: OR item/pokemon bag is full
Expand Down Expand Up @@ -164,4 +175,4 @@ private static async Task<List<FortData>> GetPokeStops(Context ctx)
return pokeStops.ToList();
}
}
}
}