Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nickname (PokemonGoF#5031)

* Update merge (PokemonGoF#1)

* Expand simple logging options (PokemonGoF#4832)

* Fix bot crash at start on permaban

* Expanded logging options

Added "logging" section to config, with options "color",
"show_datetime", "show_process_name" and "show_log_level"

* Added warning about deprecated logging_color arg

* Display log message moved

No point trying to use the logger before it's been initialised. Moved to
init_config.

* Remove milliseconds from datetime

Because really, do we need that?

* Reversed condition order for clarity

First check: "if not in config", OR
Second check: "is in config AND set to true"

If either condition matches, the logging detail will be displayed.

* Documented new log options

* Modified conditions again

Removed unnecessary second check for config values and slightly modified
parentheses as per suggestion from @mjmadsen

* Changed ) to } (PokemonGoF#4845)

Fixed an faulty character

* fix incubator logic (PokemonGoF#4848)

* corrected logic to respect snipe = true

* Update configuration_files.md (PokemonGoF#4854)

* corrected logic to respect snipe = true (PokemonGoF#4855)

* Revert "corrected logic to respect snipe = true" (PokemonGoF#4857)

* dont forget to update the docs when adding config changes... (PokemonGoF#4856)

* dont forget to update the docs when adding config changes...

* reflect config changes....

* please keep this as is (PokemonGoF#4859)

Add stuff in the right order.

* Clarify Max_distance for Sniping (PokemonGoF#4858)

* Clarify Max_distance

* Added distance unit and updated configuration_files.md

* - debug improvements for MoveToMap (PokemonGoF#4860)

- fix for Telegram to accept "@username" as "master", too, along with numeric  IDs

* Fixes catch rates. (PokemonGoF#4863)

* Implemented more granularity in the "alert_catch" parameter for Telegram
alerts.

* Add exceptions to json file read/writes (PokemonGoF#4877)

* Fix bot crash at start on permaban

* Expanded logging options

Added "logging" section to config, with options "color",
"show_datetime", "show_process_name" and "show_log_level"

* Added warning about deprecated logging_color arg

* Display log message moved

No point trying to use the logger before it's been initialised. Moved to
init_config.

* Remove milliseconds from datetime

Because really, do we need that?

* Reversed condition order for clarity

First check: "if not in config", OR
Second check: "is in config AND set to true"

If either condition matches, the logging detail will be displayed.

* Documented new log options

* Modified conditions again

Removed unnecessary second check for config values and slightly modified
parentheses as per suggestion from @mjmadsen

* Add exception handling to json file read/write ops

* Removed API call in update live stats

Instead of making a new api call, utilise stats already contained in
metrics.

* Incubate eggs fix (PokemonGoF#4881)

* Fixed incubator_eggs wrong print

* Fixed pokemon hatched from eggs not added to cached inventory

* Fix

* Fixed not using breakable incubators

* Fixed error adding pokemon to cached inventory

* Moved remove egg and add Pokemon to _hatch_eggs

* add some sanitycheck (PokemonGoF#4891)

* execute setup.sh -u if there is a need to (PokemonGoF#4870)

* execute setup.sh -u if there is a need to

* ask the user whether to run setup.sh -u or not

* fix grammatical error

* Add PokemonGo bot version to docker image (PokemonGoF#4886)

* fix pep8

* Add PokemonGo bot version to docker image

* Use https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/commits{/sha} API

* Fix remove pyc, pyo files

* Call level_up_rewards on exp changes/Some pep-8 (PokemonGoF#4896)

* Call level_up_rewards on exp changes.

* Cleanup

* Improvements to evolve + config md updates (PokemonGoF#4900)

* Better do not evolve handling

* Edit config

* Update config

* Edit config

* Edit config

* Edit config

* Update config.json.path.example

* Update config.json.map.example

* Update config.json.example

* Update config.json.cluster.example

* Updated configuration_files.md

* Add extra tests

* Update config

* Update config

* Update config

* Update config

* Update config.json.pokemon.example

* Update config.json.cluster.example

* Begin fixing configuration_files.md

* Small fix

* Small fix

* Bit for of config updated

* Bit more on config

* A few more to config md

* Bit more of of an update

* 2000 pokestop in 24h limit (PokemonGoF#4906)

* 2000 pokestop in 24h limit

* 2000 pokestop in 24h limit

* add config variable

* config update

* Update readme.md + Improve FollowPath & SleepSchedule messages (PokemonGoF#4911)

* Use logger for follow path loiter message

* Update readme.md

* Improve sleep message

* Allow follow_path to use config's distance unit

* Allow follow_path to use config's distance unit

* Reduce API calls (PokemonGoF#4916)

* Fix bot crash at start on permaban

* Expanded logging options

Added "logging" section to config, with options "color",
"show_datetime", "show_process_name" and "show_log_level"

* Added warning about deprecated logging_color arg

* Display log message moved

No point trying to use the logger before it's been initialised. Moved to
init_config.

* Remove milliseconds from datetime

Because really, do we need that?

* Reversed condition order for clarity

First check: "if not in config", OR
Second check: "is in config AND set to true"

If either condition matches, the logging detail will be displayed.

* Documented new log options

* Modified conditions again

Removed unnecessary second check for config values and slightly modified
parentheses as per suggestion from @mjmadsen

* Add exception handling to json file read/write ops

* Removed API call in update live stats

Instead of making a new api call, utilise stats already contained in
metrics.

* Update player data in web from metrics

Uses existing metrics instead of waiting on liveupdate

* Implemented more granularity in the "alert_catch" parameter for Telegram
alerts.

* Improvements to evolve + config md updates (PokemonGoF#4900)

* Better do not evolve handling

* Edit config

* Update config

* Edit config

* Edit config

* Edit config

* Update config.json.path.example

* Update config.json.map.example

* Update config.json.example

* Update config.json.cluster.example

* Updated configuration_files.md

* Add extra tests

* Update config

* Update config

* Update config

* Update config

* Update config.json.pokemon.example

* Update config.json.cluster.example

* Begin fixing configuration_files.md

* Small fix

* Small fix

* Bit for of config updated

* Bit more on config

* A few more to config md

* Bit more of of an update

* Incubate eggs fix (PokemonGoF#4881)

* Fixed incubator_eggs wrong print

* Fixed pokemon hatched from eggs not added to cached inventory

* Fix

* Fixed not using breakable incubators

* Fixed error adding pokemon to cached inventory

* Moved remove egg and add Pokemon to _hatch_eggs

* Call level_up_rewards on exp changes/Some pep-8 (PokemonGoF#4896)

* Call level_up_rewards on exp changes.

* Cleanup

* add some sanitycheck (PokemonGoF#4891)

* execute setup.sh -u if there is a need to (PokemonGoF#4870)

* execute setup.sh -u if there is a need to

* ask the user whether to run setup.sh -u or not

* fix grammatical error

* Add PokemonGo bot version to docker image (PokemonGoF#4886)

* fix pep8

* Add PokemonGo bot version to docker image

* Use https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/commits{/sha} API

* Fix remove pyc, pyo files

* Refactoring to share inventory and reduce api calls

Modifications to share cached inventory and reduce overall required api
calls from 4 to 1. Only remaining api call comes from heartbeat which
updates the cached inventory for sanity reasons.

* Remove import of UpdateWebPlayerdata

Decided there was a better way to go with this, since both
UpdateWebInventory and UpdateWebPlayerdata share the same inventory
input/output, just different sections. Combined into UpdateWebInventory.

* Fixed conflict

* Import inventory added to metrics

Allows metrics to use the cached inventory to retrieve player stats
instead of making another api call

* Removed api call from incubate_eggs

Cached inventory should be accurate enough for this

* Swap auth and config position (PokemonGoF#4909)

* add telegram check messages interval (PokemonGoF#4919)

* add telegram check messages interval

* config changed

* fix config

* telegram doc update

* Add documentation (PokemonGoF#4921)

See documentation for full list of new features

* documented docker for the auth.json use case (PokemonGoF#4922)

add instructions for the docker run command for the multiple config files use case.

* Fix for PokemonGoF#4718 (PokemonGoF#4924)

* Add except variable

* Add except variable

* Fix filter (PokemonGoF#4925)

* improve docker pull speed (PokemonGoF#4899)

* Update inventory.py (PokemonGoF#4928)

FIX: PokemonGoF#4926

* fixed a runtime error caused by incorrect imports (PokemonGoF#4931)

* Catch exception telegram.error.NetworkError.
Fixs some pylint complain.

* More config parameters for MoveToMap (PokemonGoF#4937)

* fixed a runtime error caused by incorrect imports

* Moving module-level constants (snipe parameters) into config file

* Add experimental pokemon upgrade (power-up) logic (PokemonGoF#4938)

Add upgrade cost data file
Add last pokemon level.

* Set default value of skip_rounds to 30 since many people just use the default value.
30 will behave close to human.

* Add exception handling for cached forts (PokemonGoF#4943)

* Add exception handling for cached forts

* whitespace fix

* telegram to thread

* config update

* doc update

* update web repo to have better web ui contribute.

* Using $TIMEZONE environment variable to set timezone

* fix errors

* fix errors

* Fixing clean run issues.

* During startup, no bot object.

* Added option PokemonGo-Bot-Configurator

Smoothed some things up
Added option to run PokemonGo-Bot-Configurator at the end of the
installation.

* Hotfix for EvolvePokemon (PokemonGoF#4960)

* Compatiable with old protocol define in map-chat.

* Update merge (PokemonGoF#2)

* Expand simple logging options (PokemonGoF#4832)

* Fix bot crash at start on permaban

* Expanded logging options

Added "logging" section to config, with options "color",
"show_datetime", "show_process_name" and "show_log_level"

* Added warning about deprecated logging_color arg

* Display log message moved

No point trying to use the logger before it's been initialised. Moved to
init_config.

* Remove milliseconds from datetime

Because really, do we need that?

* Reversed condition order for clarity

First check: "if not in config", OR
Second check: "is in config AND set to true"

If either condition matches, the logging detail will be displayed.

* Documented new log options

* Modified conditions again

Removed unnecessary second check for config values and slightly modified
parentheses as per suggestion from @mjmadsen

* Changed ) to } (PokemonGoF#4845)

Fixed an faulty character

* fix incubator logic (PokemonGoF#4848)

* corrected logic to respect snipe = true

* Update configuration_files.md (PokemonGoF#4854)

* corrected logic to respect snipe = true (PokemonGoF#4855)

* Revert "corrected logic to respect snipe = true" (PokemonGoF#4857)

* dont forget to update the docs when adding config changes... (PokemonGoF#4856)

* dont forget to update the docs when adding config changes...

* reflect config changes....

* please keep this as is (PokemonGoF#4859)

Add stuff in the right order.

* Clarify Max_distance for Sniping (PokemonGoF#4858)

* Clarify Max_distance

* Added distance unit and updated configuration_files.md

* - debug improvements for MoveToMap (PokemonGoF#4860)

- fix for Telegram to accept "@username" as "master", too, along with numeric  IDs

* Fixes catch rates. (PokemonGoF#4863)

* Implemented more granularity in the "alert_catch" parameter for Telegram
alerts.

* Add exceptions to json file read/writes (PokemonGoF#4877)

* Fix bot crash at start on permaban

* Expanded logging options

Added "logging" section to config, with options "color",
"show_datetime", "show_process_name" and "show_log_level"

* Added warning about deprecated logging_color arg

* Display log message moved

No point trying to use the logger before it's been initialised. Moved to
init_config.

* Remove milliseconds from datetime

Because really, do we need that?

* Reversed condition order for clarity

First check: "if not in config", OR
Second check: "is in config AND set to true"

If either condition matches, the logging detail will be displayed.

* Documented new log options

* Modified conditions again

Removed unnecessary second check for config values and slightly modified
parentheses as per suggestion from @mjmadsen

* Add exception handling to json file read/write ops

* Removed API call in update live stats

Instead of making a new api call, utilise stats already contained in
metrics.

* Incubate eggs fix (PokemonGoF#4881)

* Fixed incubator_eggs wrong print

* Fixed pokemon hatched from eggs not added to cached inventory

* Fix

* Fixed not using breakable incubators

* Fixed error adding pokemon to cached inventory

* Moved remove egg and add Pokemon to _hatch_eggs

* add some sanitycheck (PokemonGoF#4891)

* execute setup.sh -u if there is a need to (PokemonGoF#4870)

* execute setup.sh -u if there is a need to

* ask the user whether to run setup.sh -u or not

* fix grammatical error

* Add PokemonGo bot version to docker image (PokemonGoF#4886)

* fix pep8

* Add PokemonGo bot version to docker image

* Use https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/commits{/sha} API

* Fix remove pyc, pyo files

* Call level_up_rewards on exp changes/Some pep-8 (PokemonGoF#4896)

* Call level_up_rewards on exp changes.

* Cleanup

* Improvements to evolve + config md updates (PokemonGoF#4900)

* Better do not evolve handling

* Edit config

* Update config

* Edit config

* Edit config

* Edit config

* Update config.json.path.example

* Update config.json.map.example

* Update config.json.example

* Update config.json.cluster.example

* Updated configuration_files.md

* Add extra tests

* Update config

* Update config

* Update config

* Update config

* Update config.json.pokemon.example

* Update config.json.cluster.example

* Begin fixing configuration_files.md

* Small fix

* Small fix

* Bit for of config updated

* Bit more on config

* A few more to config md

* Bit more of of an update

* 2000 pokestop in 24h limit (PokemonGoF#4906)

* 2000 pokestop in 24h limit

* 2000 pokestop in 24h limit

* add config variable

* config update

* Update readme.md + Improve FollowPath & SleepSchedule messages (PokemonGoF#4911)

* Use logger for follow path loiter message

* Update readme.md

* Improve sleep message

* Allow follow_path to use config's distance unit

* Allow follow_path to use config's distance unit

* Reduce API calls (PokemonGoF#4916)

* Fix bot crash at start on permaban

* Expanded logging options

Added "logging" section to config, with options "color",
"show_datetime", "show_process_name" and "show_log_level"

* Added warning about deprecated logging_color arg

* Display log message moved

No point trying to use the logger before it's been initialised. Moved to
init_config.

* Remove milliseconds from datetime

Because really, do we need that?

* Reversed condition order for clarity

First check: "if not in config", OR
Second check: "is in config AND set to true"

If either condition matches, the logging detail will be displayed.

* Documented new log options

* Modified conditions again

Removed unnecessary second check for config values and slightly modified
parentheses as per suggestion from @mjmadsen

* Add exception handling to json file read/write ops

* Removed API call in update live stats

Instead of making a new api call, utilise stats already contained in
metrics.

* Update player data in web from metrics

Uses existing metrics instead of waiting on liveupdate

* Implemented more granularity in the "alert_catch" parameter for Telegram
alerts.

* Improvements to evolve + config md updates (PokemonGoF#4900)

* Better do not evolve handling

* Edit config

* Update config

* Edit config

* Edit config

* Edit config

* Update config.json.path.example

* Update config.json.map.example

* Update config.json.example

* Update config.json.cluster.example

* Updated configuration_files.md

* Add extra tests

* Update config

* Update config

* Update config

* Update config

* Update config.json.pokemon.example

* Update config.json.cluster.example

* Begin fixing configuration_files.md

* Small fix

* Small fix

* Bit for of config updated

* Bit more on config

* A few more to config md

* Bit more of of an update

* Incubate eggs fix (PokemonGoF#4881)

* Fixed incubator_eggs wrong print

* Fixed pokemon hatched from eggs not added to cached inventory

* Fix

* Fixed not using breakable incubators

* Fixed error adding pokemon to cached inventory

* Moved remove egg and add Pokemon to _hatch_eggs

* Call level_up_rewards on exp changes/Some pep-8 (PokemonGoF#4896)

* Call level_up_rewards on exp changes.

* Cleanup

* add some sanitycheck (PokemonGoF#4891)

* execute setup.sh -u if there is a need to (PokemonGoF#4870)

* execute setup.sh -u if there is a need to

* ask the user whether to run setup.sh -u or not

* fix grammatical error

* Add PokemonGo bot version to docker image (PokemonGoF#4886)

* fix pep8

* Add PokemonGo bot version to docker image

* Use https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/commits{/sha} API

* Fix remove pyc, pyo files

* Refactoring to share inventory and reduce api calls

Modifications to share cached inventory and reduce overall required api
calls from 4 to 1. Only remaining api call comes from heartbeat which
updates the cached inventory for sanity reasons.

* Remove import of UpdateWebPlayerdata

Decided there was a better way to go with this, since both
UpdateWebInventory and UpdateWebPlayerdata share the same inventory
input/output, just different sections. Combined into UpdateWebInventory.

* Fixed conflict

* Import inventory added to metrics

Allows metrics to use the cached inventory to retrieve player stats
instead of making another api call

* Removed api call from incubate_eggs

Cached inventory should be accurate enough for this

* Swap auth and config position (PokemonGoF#4909)

* add telegram check messages interval (PokemonGoF#4919)

* add telegram check messages interval

* config changed

* fix config

* telegram doc update

* Add documentation (PokemonGoF#4921)

See documentation for full list of new features

* documented docker for the auth.json use case (PokemonGoF#4922)

add instructions for the docker run command for the multiple config files use case.

* Fix for PokemonGoF#4718 (PokemonGoF#4924)

* Add except variable

* Add except variable

* Fix filter (PokemonGoF#4925)

* improve docker pull speed (PokemonGoF#4899)

* Update inventory.py (PokemonGoF#4928)

FIX: PokemonGoF#4926

* fixed a runtime error caused by incorrect imports (PokemonGoF#4931)

* Catch exception telegram.error.NetworkError.
Fixs some pylint complain.

* More config parameters for MoveToMap (PokemonGoF#4937)

* fixed a runtime error caused by incorrect imports

* Moving module-level constants (snipe parameters) into config file

* Add experimental pokemon upgrade (power-up) logic (PokemonGoF#4938)

Add upgrade cost data file
Add last pokemon level.

* Set default value of skip_rounds to 30 since many people just use the default value.
30 will behave close to human.

* Add exception handling for cached forts (PokemonGoF#4943)

* Add exception handling for cached forts

* whitespace fix

* telegram to thread

* config update

* doc update

* update web repo to have better web ui contribute.

* Using $TIMEZONE environment variable to set timezone

* fix errors

* fix errors

* Fixing clean run issues.

* During startup, no bot object.

* Added option PokemonGo-Bot-Configurator

Smoothed some things up
Added option to run PokemonGo-Bot-Configurator at the end of the
installation.

* Hotfix for EvolvePokemon (PokemonGoF#4960)

* Compatiable with old protocol define in map-chat.

* Provided a default for max_walking_distance and max_sniping_distance in
order to avoid unhandled exceptions

* Made sure nicknaming only waits if real api-relevant action was taken.
  • Loading branch information
rawgni committed Sep 1, 2016
1 parent f73455c commit 7a05ffd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
18 changes: 8 additions & 10 deletions pokemongo_bot/cell_workers/collect_level_up_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ def _collect_level_reward(self):
item['name'] = got_item
count = 'item_count' in item and item['item_count'] or 0
inventory.items().get(item['item_id']).add(count)
try:
self.emit_event(
'level_up_reward',
formatted='Received level up reward: {items}',
data={
'items': ', '.join(["{}x {}".format(data[x], x) for x in data])
}
)
except TypeError:
pass
self.emit_event(
'level_up_reward',
formatted='Received level up reward: {items}',
data={
# [{'item_id': 3, 'name': u'Ultraball', 'item_count': 10}, {'item_id': 103, 'name': u'Hyper Potion', 'item_count': 10}]
'items': ', '.join(["{}x {}".format(x['item_count'], x['name']) for x in data])
}
)
10 changes: 6 additions & 4 deletions pokemongo_bot/cell_workers/move_to_map_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ def get_pokemon_from_social(self):
pokemon['longitude'],
)

if pokemon['dist'] > self.config['max_sniping_distance'] and self.config['snipe']:
# If distance to pokemon greater than the max_sniping_distance, then ignore regardless of "snipe" setting
if pokemon['dist'] > self.config.get('max_sniping_distance', 10000):
continue

if pokemon['dist'] > self.config['max_walking_distance'] and not self.config['snipe']:

# If distance bigger than walking distance, ignore if sniping is not active
if pokemon['dist'] > self.config.get('max_walking_distance', 1000) and not self.config.get('snipe', False):
continue

# pokemon not reachable with mean walking speed (by config)
# if pokemon not reachable with mean walking speed (by config)
mean_walk_speed = (self.bot.config.walk_max + self.bot.config.walk_min) / 2
if pokemon['dist'] > ((pokemon['disappear_time'] - now) * mean_walk_speed) and not self.config['snipe']:
continue
Expand Down
20 changes: 11 additions & 9 deletions pokemongo_bot/cell_workers/nickname_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import json
from pokemongo_bot.base_task import BaseTask
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.human_behaviour import sleep, action_delay
from pokemongo_bot.inventory import pokemons, Pokemon, Attack

import re
Expand Down Expand Up @@ -210,9 +210,9 @@ def work(self):
for pokemon in pokemons().all(): # type: Pokemon
if not pokemon.is_favorite or not self.ignore_favorites:
if pokemon.iv >= self.nickname_above_iv:
# Make the bot appears more human
action_delay(self.nickname_wait_min, self.nickname_wait_max)
self._nickname_pokemon(pokemon)
if self._nickname_pokemon(pokemon):
# Make the bot appears more human
action_delay(self.nickname_wait_min, self.nickname_wait_max)

def _localize(self, string):
if self.translate and string in self.translate:
Expand All @@ -221,7 +221,8 @@ def _localize(self, string):
return string

def _nickname_pokemon(self, pokemon):
# type: (Pokemon) -> None
# type: (Pokemon) -> bool
# returns False if no wait needed (no API calls tried before return), True if wait is needed
"""
Nicknaming process
"""
Expand All @@ -233,7 +234,7 @@ def _nickname_pokemon(self, pokemon):
'api_error',
formatted='Failed to get pokemon name, will not rename.'
)
return
return False

# Generate new nickname
old_nickname = pokemon.nickname
Expand All @@ -245,11 +246,11 @@ def _nickname_pokemon(self, pokemon):
formatted="Unable to nickname {} due to bad template ({})"
.format(old_nickname, bad_key)
)
return
return False

# Skip if pokemon is already well named
if pokemon.nickname_raw == new_nickname:
return
return False

# Send request
response = self.bot.api.nickname_pokemon(
Expand All @@ -265,7 +266,7 @@ def _nickname_pokemon(self, pokemon):
'api_error',
formatted='Attempt to nickname received bad response from server.'
)
return
return True

# Nickname unset
if result == 0:
Expand Down Expand Up @@ -294,6 +295,7 @@ def _nickname_pokemon(self, pokemon):
formatted='Attempt to nickname received unexpected result'
' from server ({}).'.format(result)
)
return True

def _generate_new_nickname(self, pokemon, template):
# type: (Pokemon, string) -> string
Expand Down

0 comments on commit 7a05ffd

Please sign in to comment.