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

When daily spin limit is reached, let it continue working instead of … #5550

Merged
merged 4 commits into from
Sep 26, 2016

Conversation

kolinkorr839
Copy link
Contributor

Short Description:

When the daily spin limit is reached, the script exits. This change allow the script to continue but gives a warning that the spin limit is reached every 120 seconds (default which can be changed).

Sample output:

[2016-09-19 11:54:53] [  SpinFort] [INFO] Spun pokestop First Street. Experience awarded: 50. Items awarded: 1x Potion, 2x Pokeball
[2016-09-19 11:54:53] [  SpinFort] [INFO] WARNING! You have reached your daily spin limit
[2016-09-19 11:54:58] [MoveToFort] [INFO] Moving towards pokestop Mosaic Seats - 0.07km
[2016-09-19 11:55:03] [MoveToFort] [INFO] Moving towards pokestop Mosaic Seats - 0.06km
[2016-09-19 11:55:09] [MoveToFort] [INFO] Moving towards pokestop Mosaic Seats - 0.04km
[2016-09-19 11:55:10] [  SpinFort] [INFO] Spun pokestop Mosaic Seats. Experience awarded: 50. Items awarded: 3x Pokeball

@mention-bot
Copy link

@kolinkorr839, thanks for your PR! By analyzing the annotation information on this pull request, we identified @askovpen, @douglascamata and @BriceSD to be potential reviewers

@solderzzc
Copy link
Contributor

It's better to add an option to allow user decide if quit when hit daily limit.
The daily limit is a very good protection.

sys.exit(2)
if datetime.now() >= self.next_update:
self.emit_event('spin_limit', formatted='WARNING! You have reached your daily spin limit')
self._compute_next_update()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should stop running work here. Maybe add return WorkerResult.ERROR (or SUCCESS depending on your interpretation of this result)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running is done by MoveToFort or FollowSpiral etc., not by SpinFort. I am also not sure whether returning ERROR here would count towards softban detection... So returning SUCCESS is probably the most nonintrusive way.

Plus - sometimes, you want actually to continue running and apturing pokemons and sniping even with a reached daily limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new variable called 'bypass_daily_limit'. This is "false" by default and if the daily_spin_limit is reached, the code will exit. This is the current behavior.

But if the 'bypass_daily_limit' is set to true and the daily_spin_limit is reached, the bot will continue its business but it will give a warning message that the daily spin limit has been reached every 120 seconds (through the min_interval variable which can be changed).

Copy link
Contributor

@Gobberwart Gobberwart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one minor issue. Please add something to break out of work method if daily limit reached (eg. return WorkerResult.ERROR/SUCCESS)

Copy link
Contributor

@DBa2016 DBa2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New parameter, needs at the very least to be documented in "config.json.sample" and in "configuration_files.md" - also I suggest renaming it to be more descriptive.

sys.exit(2)
if datetime.now() >= self.next_update:
self.emit_event('spin_limit', formatted='WARNING! You have reached your daily spin limit')
self._compute_next_update()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running is done by MoveToFort or FollowSpiral etc., not by SpinFort. I am also not sure whether returning ERROR here would count towards softban detection... So returning SUCCESS is probably the most nonintrusive way.

Plus - sometimes, you want actually to continue running and apturing pokemons and sniping even with a reached daily limit.

self.ignore_item_count = self.config.get("ignore_item_count", False)
self.spin_wait_min = self.config.get("spin_wait_min", 2)
self.spin_wait_max = self.config.get("spin_wait_max", 3)
self.min_interval = int(self.config.get('min_interval', 120))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest renaming "min_interval" to something more descriptive. Maybe "pause_on_daily_limit" or similar.

Also, it needs documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout the code, the 'min_interval' is used to show some logging/stats updates. This is the reason why I decided to keep this name since its purpose is to show a warning the the spin limit has been reached.

I have added some documentation for this variable as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DBa2016 min_interval is just about the warning message, doesn't pause the bot etc.

@kolinkorr839
Copy link
Contributor Author

Here's 2 tests that I did.

If bypass_daily_limit is not changed (default to false), this is the output when daily_spin_limit is reached (it stops the script just like it does right now)

[2016-09-20 15:13:15] [MoveToFort] Moving towards pokestop Sister Cities Bench 1 - 0.04km (attraction of lure 0.04km)
[2016-09-20 15:13:19] [  SpinFort] Spun pokestop Sister Cities Bench 1. Experience awarded: 50. Items awarded: 3x Pokeball
[2016-09-20 15:13:24] [MoveToFort] Moving towards pokestop San Francisco Ferry Terminal Landmark  - 0.05km (attraction of lure 0.05km)
[2016-09-20 15:13:27] [  SpinFort] Spun pokestop San Francisco Ferry Terminal Landmark . Experience awarded: 50. Items awarded: 1x Potion, 2x Pokeball
[2016-09-20 15:13:31] [MoveToFort] Moving towards pokestop In Memory of Herb Caen - 0.08km
[2016-09-20 15:13:37] [MoveToFort] Moving towards pokestop In Memory of Herb Caen - 0.06km
[2016-09-20 15:13:42] [MoveToFort] Moving towards pokestop In Memory of Herb Caen - 0.05km (attraction of lure 0.05km)
[2016-09-20 15:13:47] [  SpinFort] Spun pokestop In Memory of Herb Caen. Experience awarded: 50. Items awarded: 2x Pokeball, 1x Greatball
[2016-09-20 15:13:50] [MoveToFort] Moving towards pokestop Pier 1 1/2, 3 & 5 Historic Site - 0.08km
[2016-09-20 15:13:52] [  SpinFort] WARNING! You have reached your daily spin limit

If bypass_daily_limit is set to true, this is the output when daily_spin_limit is reached which allows the bot to continue doing its business. But it gives a warning from time to time that the daily_spin_limit has been reached

[2016-09-20 15:16:37] [MoveToFort] Moving towards pokestop The River Lines - 0.04km (attraction of lure 0.04km)
[2016-09-20 15:16:39] [  SpinFort] Spun pokestop The River Lines. Experience awarded: 50. Items awarded: 2x Pokeball, 1x Hyper Potion
[2016-09-20 15:16:43] [MoveToFort] Moving towards pokestop Embarcadero Freeway To Nowhere Comes Down - 0.09km
[2016-09-20 15:16:44] [  SpinFort] WARNING! You have reached your daily spin limit
[2016-09-20 15:16:48] [MoveToFort] Moving towards pokestop Embarcadero Freeway To Nowhere Comes Down - 0.07km
[2016-09-20 15:16:54] [MoveToFort] Moving towards pokestop Embarcadero Freeway To Nowhere Comes Down - 0.05km
[2016-09-20 15:16:59] [  SpinFort] Spun pokestop Embarcadero Freeway To Nowhere Comes Down. Experience awarded: 50. Items awarded: 3x Pokeball
....
....
[2016-09-20 15:18:32] [MoveToFort] Moving towards pokestop Pier 7 - 0.04km
[2016-09-20 15:18:35] [  SpinFort] Spun pokestop Pier 7. Experience awarded: 100. Items awarded: 1x Razz Berry, 1x Potion, 3x Pokeball, 1x Revive
[2016-09-20 15:18:39] [MoveToFort] Moving towards pokestop Dangerous Sailor Lives - 0.07km
[2016-09-20 15:18:45] [  SpinFort] WARNING! You have reached your daily spin limit
[2016-09-20 15:18:45] [MoveToFort] Moving towards pokestop Dangerous Sailor Lives - 0.05km

@Gobberwart
Copy link
Contributor

You'll need to rebase this, it's showing a bunch of commits that aren't related to this PR

if datetime.now() >= self.next_update:
self.emit_event('spin_limit', formatted='WARNING! You have reached your daily spin limit')
self._compute_next_update()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs to stop and return from this method. No point running the rest of the work code if daily_spin_limit is reached.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true.. I will make the change.

@@ -207,6 +207,9 @@ The behaviors of the bot are configured via the `tasks` key in the `config.json`
* `enable`: Disable or enable this task.
* `spin_wait_min`: Default 3 | Minimum wait time after fort spin
* `spin_wait_max`: Default 5 | Maximum wait time after fort spin
* `daily_spin_limit`: Default 2000 | Daily spin limit
* `min_interval`: Default 120 | When daily spin limit is reached, how often should the warning message be shown
* `bypass_daily_limit`: Default `False` | Disable the spin daily limit protection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about "bypass_daily_limit" as a name, since that's not really what it does. If this is true, it lets the bot continue to catch/evolve/transfer etc without spinning forts. The limit is still observed, just the behavior when limit is reached is different.

Maybe: 'exit_on_limit_reached': true/false (default False) and reverse the way the condition works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. 'exit_on_limit_reached' sounds better. I will make the change.

@Gobberwart
Copy link
Contributor

The only outstanding issue I can see is from @DBa2016 Plus - sometimes, you want actually to continue running and apturing pokemons and sniping even with a reached daily limit.

Maybe this could have a "warning only" mode AS WELL, which generates log messages, but still functions anyway.

@Gobberwart
Copy link
Contributor

OK so dba2016's concern has been addressed. Not sure if we REALLY need that third option then (bypass_daily_limit). Just exit or continue, as it is now.

…se, then the code will exit.

When daily_spin_limit is reached and bypass_daily_limit is set to true, then the bot will continue its business.
It will send a message every 2 minutes (default but can be changed) that the daily spin limit has been reached.
@Gobberwart
Copy link
Contributor

OK, looks good. Merging.

@Gobberwart Gobberwart merged commit ec893ec into PokemonGoF:dev Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants