Skip to content

Commit

Permalink
Merge pull request #6039 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Dev merge to master
  • Loading branch information
pogarek authored May 15, 2017
2 parents 263da69 + 1da9f62 commit 1f2b1cf
Show file tree
Hide file tree
Showing 20 changed files with 552 additions and 161 deletions.
3 changes: 3 additions & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"evolve_only_with_lucky_egg": false,
"evolve_count_for_lucky_egg": 80,
"may_use_lucky_egg": true,
"may_evolve_favorites": true,
"may_upgrade_favorites": true,
"may_unfavor_pokemon": false,
"upgrade": true,
"upgrade_level": 30,
"groups": {
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
"path_start_mode": "first",
"path_file": "configs/path.example.json",
"number_lap": 10,
"disable_location_output": false,
"timer_restart_min": "00:10:00",
"timer_restart_max": "00:20:00"
}
Expand Down
53 changes: 53 additions & 0 deletions docs/auto_restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,56 @@ restart:
end tell

end repeat

# For any other linux distribution

> You can use the this script to make your bot auto-restart
```
#!/usr/bin/bash
while true ; do
#Add your bot start command after this comment
echo "If you want to completely the restart process now, press Ctrl+C before the time is up!"
echo "Restarting bot in 2 minute"
sleep 1m
echo "Restarting bot in 1 minute"
sleep 30s
echo "Restarting bot in 30 seconds"
sleep 10s
echo "Restarting bot in 20 seconds"
sleep 10s
echo "Restarting bot in 10 seconds"
sleep 5s
echo "Restarting bot in 5 seconds"
sleep 1s
echo "Restarting bot in 4 seconds"
sleep 1s
echo "Restarting bot in 3 seconds"
sleep 1s
echo "Restarting bot in 2 seconds"
sleep 1s
echo "Restarting bot in 1 seconds"
sleep 1s
echo "Restarting now !"
done
```

You just need to add your command to start the bot after the comment

And after you need to do this:
```
chmod 755 <scriptname>
```
If you get an error like this:
```
-bash: ./loop.sh: /usr/bin/bash^M: bad interpreter: No such file or directory
```
You need to convert the script in dos

```
dos2unix scriptname.sh
```
2 changes: 2 additions & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ The behaviors of the bot are configured via the `tasks` key in the `config.json`
* `use_lucky_egg`: Default: `False` | Only evolve if we can use a lucky egg
* FollowPath
* `enable`: Disable or enable this task.
* `disable_while_hunting`: Default `true` | Disable walking when Pokemon Hunter has a target locked.
* `path_mode`: Default `loop` | Set the mode for the path navigator (loop, linear or single).
* `path_file`: Default `NONE` | Set the file containing the waypoints for the path navigator.
* FollowSpiral
Expand Down Expand Up @@ -935,6 +936,7 @@ option.
- `first` - The bot will start at the first point of the path.
- `closest` - The bot will start the path at the point which is the closest to the current bot location.
* `path_file` - "/path/to/your/path.json"
* `disable_location_output` - true,false. Set to true if you do not want to see follow path updating information. Default false.

### Notice
If you use the `single` `path_mode` without e.g. a `MoveToFort` task, your bot
Expand Down
18 changes: 10 additions & 8 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ docker run --name=bot1-pokegoweb --rm -it --volumes-from bot1-pokego -p 8000:800
```
The OpenPoGoWeb will be served on `http://<your host>:8000`

### Using proxy with docker:

- https proxy
```
docker run --name=bot1-pokego -e "https_proxy=https://PROXY_IP:PORT" --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongocc-bot
```
- http proxy
```
docker run --name=bot1-pokego -e "http_proxy=http://PROXY_IP:PORT" --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongo-bot
```

### Remarks for Windows

Expand Down Expand Up @@ -136,14 +146,6 @@ docker run --name=bot1-pokegoweb --rm -it --volumes-from bot1-pokego -p 8000:800
Then, with your containers running and your host address, you can access the web view in your browser:

`http://<your host address>:8000 (eg http://192.168.99.100:8000)`
Using proxy with docker:
- https proxy
```
docker run --name=bot1-pokego -e "https_proxy=https://PROXY_IP:PORT" --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongo-bot
```
- http proxy
```
docker run --name=bot1-pokego -e "http_proxy=http://PROXY_IP:PORT" --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongo-bot
```
#### Errors
Expand Down
74 changes: 72 additions & 2 deletions docs/pokemon_optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- [evolve_only_with_lucky_egg](#evolve_only_with_lucky_egg)
- [evolve_count_for_lucky_egg](#evolve_count_for_lucky_egg)
- [may_use_lucky_egg](#may_use_lucky_egg)
- [may_evolve_favorites](#may_evolve_favorites)
- [may_upgrade_favorites](#may_upgrade_favorites)
- [may_unfavor_pokemon](#may_unfavor_pokemon)
- [upgrade](#upgrade)
- [upgrade_level](#upgrade_level)
- [groups](#groups)
Expand All @@ -29,6 +32,7 @@
- [evolve](#rule-evolve)
- [upgrade](#rule-upgrade)
- [buddy](#rule-buddy)
- [favorite](#rule-favorite)
- [Eevee case](#eevee-case)
- [FAQ](#faq)

Expand All @@ -42,7 +46,7 @@ There is only one pass at each action.

It will also collect the candies from your Buddy and select the next buddy.

In case that logging will be enabled, look for .log file in data folder.
In case that logging will be enabled, look for .log file in data folder.

[[back to top](#pokemon-optimizer)]

Expand All @@ -69,6 +73,9 @@ In case that logging will be enabled, look for .log file in data folder.
"evolve_only_with_lucky_egg": false,
"evolve_count_for_lucky_egg": 80,
"may_use_lucky_egg": true,
"may_evolve_favorites": true,
"may_upgrade_favorites": true,
"may_unfavor_pokemon": false,
"upgrade": true,
"upgrade_level": 30,
"groups": {
Expand Down Expand Up @@ -333,6 +340,39 @@ Define whether you allow the Pokemon Optimizer to use a lucky egg before evolvin

[[back to top](#pokemon-optimizer)]

### may_evolve_favorites
| Parameter | Possible values | Default |
|---------------------|-----------------|---------|
| `may_evolve_favorites` | `true`, `false` | `true` |

Define whether you allow the Pokemon Optimizer to evolve favorite Pokemon or not.
<br>At `true`, the Pokemon Optimizer will evolve favorite Pokemon according to the rules.
<br>At `false`, the Pokemon Optimizer will not evolve favorite Pokemon.

[[back to top](#pokemon-optimizer)]

### may_upgrade_favorites
| Parameter | Possible values | Default |
|---------------------|-----------------|---------|
| `may_upgrade_favorites` | `true`, `false` | `true` |

Define whether you allow the Pokemon Optimizer to upgrade favorite Pokemon or not.
<br>At `true`, the Pokemon Optimizer will upgrade favorite Pokemon according to the rules.
<br>At `false`, the Pokemon Optimizer will not upgrade favorite Pokemon.

[[back to top](#pokemon-optimizer)]

### may_unfavor_pokemon
| Parameter | Possible values | Default |
|---------------------|-----------------|---------|
| `may_unfavor_pokemon` | `true`, `false` | `false` |

Define whether you allow the Pokemon Optimizer to unmark favorite Pokemon as favorite or not.
<br>At `true`, the Pokemon Optimizer will unmark favorite Pokemon if it no longer matches favorite rules.
<br>At `false`, the Pokemon Optimizer will not unmark favorite Pokemon.

[[back to top](#pokemon-optimizer)]

### upgrade
| Parameter | Possible values | Default |
|-----------|-----------------|---------|
Expand Down Expand Up @@ -637,6 +677,8 @@ By default, if `evolve` is not provided or is empty, no Pokemon will be evolved.
The parameter can be a boolean value (`true` or `false`) or a list a criteria.
The available criteria are the same as for the [`sort`](#available-criteria) parameter.

*Note!* If [may_evolve_favorites](#may_evolve_favorites) is `false`, favorite Pokemon will never be evolved!

The minimum requirement values can be a single value or a range.
<br>They can also be a negative value if you wish to evolve Pokemon below a certain criteria:

Expand All @@ -663,8 +705,10 @@ By default, if `upgrade` is not provided or is empty, no Pokemon will be upgrade
The parameter can be a boolean value (`true` or `false`) or a list a criteria.
The available criteria are the same as for the [`sort`](#available-criteria) parameter.

*Note!* If [may_upgrade_favorites](#may_upgrade_favorites) is `false`, favorite Pokemon will never be upgraded!

The minimum requirement values can be a single value or a range.
<br>They can also be a negative value if you wish to evolve Pokemon below a certain criteria:
<br>They can also be a negative value if you wish to upgrade Pokemon below a certain criteria:

- `"upgrade": false` will not try to upgrade any of the Pokemon selected.
- `"upgrade": true` will try to upgrade all Pokemon selected.
Expand All @@ -677,6 +721,32 @@ The minimum requirement values can be a single value or a range.

[[back to top](#pokemon-optimizer)]

#### rule favorite
| Parameter | Possible values | Default |
|-----------|-----------------|---------|
| `favorite` | (see below) | `false` |

Define minimum requirements to favorite the Pokemon.
Only Pokemon meeting these minimum requirements will be marked as favorite.
By default, if `favorite` is not provided or is empty, no Pokemon will be marked favorite.

The parameter can be a boolean value (`true` or `false`) or a list a criteria.
The available criteria are the same as for the [`sort`](#available-criteria) parameter.

The minimum requirement values can be a single value or a range.
<br>They can also be a negative value if you wish to mark Pokemon below a certain criteria as favorite:

- `"favorite": false` will not try to mark any of the Pokemon selected as favorite.
- `"favorite": true` will try to mark all Pokemon selected as favorite.
- `"favorite": {"iv": 0.9}` will only favorite Pokemon with `iv` greater than `0.9`.
- `"favorite": {"iv": 0.9, "cp": 1200}` will only favorite Pokemon with `iv` greater than `0.9` and `cp` greater than `1200`.
- `"favorite": {"iv": 0.9}` will only favorite Pokemon with `iv` greater than `0.9`.
- `"favorite": {"cp": -20}` will only favorite Pokemon with `cp` lower than `20`.
- `"favorite": {"cp": [10, 20]}` will only favorite Pokemon with `cp` between `10` and `20`.
- `"favorite": {"iv": [[0.3, 0.5], [0.9, 1.0]]}` will only favorite Pokemon with `iv` between `0.3` and `0.5` or between `0.9` and `1.0`.

[[back to top](#pokemon-optimizer)]

#### rule buddy
| Parameter | Possible values | Default |
|-----------|-----------------|---------|
Expand Down
37 changes: 33 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from .inventory import init_inventory, player
from sys import platform as _platform
from pgoapi.protos.pogoprotos.enums import badge_type_pb2
from pgoapi.exceptions import AuthException, NotLoggedInException, ServerSideRequestThrottlingException, ServerBusyOrOfflineException, NoPlayerPositionSetException
from pgoapi.exceptions import AuthException, NotLoggedInException, ServerSideRequestThrottlingException, ServerBusyOrOfflineException, NoPlayerPositionSetException, HashingOfflineException
from pgoapi.hash_server import HashServer


Expand Down Expand Up @@ -213,6 +213,8 @@ def _register_events(self):
self.event_manager.register_event('login_failed')
self.event_manager.register_event('login_successful')

self.event_manager.register_event('niantic_warning')

self.event_manager.register_event('set_start_location')
self.event_manager.register_event('load_cached_location')
self.event_manager.register_event('location_cache_ignored')
Expand All @@ -237,6 +239,7 @@ def _register_events(self):
'threshold'
)
)
self.event_manager.register_event('followpath_output_disabled')
self.event_manager.register_event(
'position_update',
parameters=(
Expand Down Expand Up @@ -507,15 +510,23 @@ def _register_events(self):
)
self.event_manager.register_event(
'pokemon_evolved',
parameters=('pokemon', 'iv', 'cp', 'candy', 'xp')
parameters=('pokemon', 'new', 'iv', 'old_cp', 'cp', 'candy', 'xp')
)
self.event_manager.register_event(
'pokemon_favored',
parameters=('pokemon', 'iv', 'cp')
)
self.event_manager.register_event(
'pokemon_unfavored',
parameters=('pokemon', 'iv', 'cp')
)
self.event_manager.register_event(
'pokemon_evolve_check',
parameters=('has', 'needs')
)
self.event_manager.register_event(
'pokemon_upgraded',
parameters=('pokemon', 'iv', 'cp', 'candy', 'stardust')
parameters=('pokemon', 'iv', 'cp', 'new_cp', 'candy', 'stardust')
)
self.event_manager.register_event('skip_evolve')
self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))
Expand Down Expand Up @@ -1173,9 +1184,12 @@ def _print_character_info(self):
# print('Response dictionary: \n\r{}'.format(json.dumps(response_dict, indent=2)))
currency_1 = "0"
currency_2 = "0"
warn = False

if response_dict:
self._player = response_dict['responses']['GET_PLAYER']['player_data']
if 'warn' in response_dict['responses']['GET_PLAYER']:
warn = response_dict['responses']['GET_PLAYER']['warn']
player = self._player
else:
self.logger.info(
Expand Down Expand Up @@ -1256,6 +1270,16 @@ def _print_character_info(self):
' | Dragon Scale: ' + str(items_inventory.get(1104).count) +
' | Upgrade: ' + str(items_inventory.get(1105).count))

if warn:
self.logger.info('')
self.event_manager.emit(
'niantic_warning',
sender=self,
level='warning',
formatted="This account has recieved a warning from Niantic. Bot at own risk."
)
sleep(5) # Pause to allow user to see warning

self.logger.info('')

def _print_list_pokemon(self):
Expand Down Expand Up @@ -1517,7 +1541,12 @@ def heartbeat(self):
request = self.api.create_request()
request.get_player()
request.check_awarded_badges()
responses = request.call()
try:
responses = request.call()
except NotLoggedInException:
self.logger.warning('Unable to login, retying')
except:
self.logger.warning('Error occured in heatbeat, retying')

if responses['responses']['GET_PLAYER']['success'] == True:
# we get the player_data anyway, might as well store it
Expand Down
Loading

0 comments on commit 1f2b1cf

Please sign in to comment.