From c510b1938778472281bb5435f983d776a6a399e9 Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Mon, 29 Aug 2016 14:39:45 -0700 Subject: [PATCH 1/6] Use logger for follow path loiter message --- pokemongo_bot/cell_workers/follow_path.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py index 6b2ed51cbe..5a36e2b02f 100644 --- a/pokemongo_bot/cell_workers/follow_path.py +++ b/pokemongo_bot/cell_workers/follow_path.py @@ -187,8 +187,8 @@ def work(self): ) if dist <= 1 or (self.bot.config.walk_min > 0 and is_at_destination) or (self.status == STATUS_LOITERING and time.time() >= self.loiter_end_time): - if "loiter" in point and self.status != STATUS_LOITERING: - print("Loitering {} seconds".format(point["loiter"])) + if "loiter" in point and self.status != STATUS_LOITERING: + self.logger.info("Loitering for {} seconds...".format(point["loiter"])) self.status = STATUS_LOITERING self.loiter_end_time = time.time() + point["loiter"] return WorkerResult.SUCCESS From c1e7c4ea378a199daa3c33b8da04cef31ae7b1ea Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Mon, 29 Aug 2016 14:50:44 -0700 Subject: [PATCH 2/6] Update readme.md --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a64e5774ea..4e62f39504 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ # PokemonGo-Bot -PokemonGo bot is a project created by the [PokemonGoF](https://github.com/PokemonGoF) team. +[PokemonGo-Bot](https://github.com/PokemonGoF/PokemonGo-Bot) is a project created by the [PokemonGoF](https://github.com/PokemonGoF) team. ## Table of Contents - [Installation](https://github.com/PokemonGoF/PokemonGo-Bot/blob/dev/docs/installation.md) - [Documentation](https://github.com/PokemonGoF/PokemonGo-Bot/blob/dev/docs/) - [Support](#support) - - [help](#configuration-issueshelp) - - [bugs](#bugs--issues) - - [Feature request](#feature-requests) + - [Help](#configuration-issueshelp) + - [Bugs](#bugs--issues) + - [Feature Requests](#feature-requests) - [Pull Requests](#pull-requests) - [Features](#features) - [Credits](#credits) -The project is currently setup in two main branches. -- `dev` also known as `beta` - This is where the latest features are, but you may also experience some issues with stability/crashes -- `master` also known as `stable` - The bot 'should' be stable on this branch, and is generally well tested +The project is currently setup in two main branches: +- `dev` also known as `beta` - This is where the latest features are, but you may also experience some issues with stability/crashes. +- `master` also known as `stable` - The bot 'should' be stable on this branch, and is generally well tested. ## Support ### Configuration issues/help If you need any help please don't create an issue as we have a great community on Slack. You can count on the community in [#help](https://pokemongo-bot.slack.com/messages/help/) channel. - - [Click here to signup (first time only)](https://pokemongo-bot.herokuapp.com) - - [Join if you're already a member](https://pokemongo-bot.slack.com/messages/general/). + - [Click here to signup (first time only)](https://pokemongo-bot.herokuapp.com) + - [Join here if you're already a member](https://pokemongo-bot.slack.com/messages/general/) ###[Bugs / Issues](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc) If you discover a bug in the bot, please [search our issue tracker](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc) first. If it hasn't been reported, please [create a new issue](https://github.com/PokemonGoF/PokemonGo-Bot/issues/new) and ensure you follow the template guide so that our team can assist you as quickly as possible. @@ -51,10 +51,10 @@ If you'd like to make your own changes, make sure you follow the pull request te - [ ] Use candy ## Gym Battles -This bot takes a strong stance against automating gym battles. Botting gyms will have a negative effect on most players and thus the game as a whole. We will thus never accept contributions or changes containing code specific for gym battles. +[PokemonGo-Bot](https://github.com/PokemonGoF/PokemonGo-Bot) takes a strong stance against automating gym battles. Botting gyms will have a negative effect on most players and thus the game as a whole. We will thus never accept contributions or changes containing code specific for gym battles. ## Analytics -This bot is very popular and has a vibrant community. Because of that, it has become very difficult for us to know how the bot is used and what errors people hit. By capturing small amounts of data, we can prioritize our work better such as fixing errors that happen to a large percentage of our user base, not just a vocal minority. +[PokemonGo-Bot](https://github.com/PokemonGoF/PokemonGo-Bot) is very popular and has a vibrant community. Because of that, it has become very difficult for us to know how the bot is used and what errors people hit. By capturing small amounts of data, we can prioritize our work better such as fixing errors that happen to a large percentage of our user base, not just a vocal minority. Our goal is to help inform our decisions by capturing data that helps us get aggregate usage and error reports, not personal information. To view the code that handles analytics in our master branch, you can use this [search link](https://github.com/PokemonGoF/PokemonGo-Bot/search?utf8=%E2%9C%93&q=BotEvent). From 9db6a464b00045eab7e6340f38b7bb57f67f6369 Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Mon, 29 Aug 2016 15:39:19 -0700 Subject: [PATCH 3/6] Improve sleep message --- pokemongo_bot/__init__.py | 5 ++++- pokemongo_bot/sleep_schedule.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 8a332fcd6d..971f1ea0b6 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -235,7 +235,10 @@ def _register_events(self): # sleep stuff self.event_manager.register_event( 'next_sleep', - parameters=('time',) + parameters=( + 'time', + 'duration' + ) ) self.event_manager.register_event( 'bot_sleep', diff --git a/pokemongo_bot/sleep_schedule.py b/pokemongo_bot/sleep_schedule.py index bfa4e044fb..3ce10e24ef 100644 --- a/pokemongo_bot/sleep_schedule.py +++ b/pokemongo_bot/sleep_schedule.py @@ -101,9 +101,10 @@ def _schedule_next_sleep(self): self.bot.event_manager.emit( 'next_sleep', sender=self, - formatted="Next sleep at {time}", + formatted="Next sleep at {time}, for a duration of {duration}", data={ - 'time': str(self._next_sleep) + 'time': str(self._next_sleep.strftime("%H:%M:%S")), + 'duration': str(timedelta(seconds=self._next_duration)) } ) From b4b97d5938f00c24dd2d1a2b49cbebb0efa5fcab Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Mon, 29 Aug 2016 16:06:21 -0700 Subject: [PATCH 4/6] Allow follow_path to use config's distance unit --- pokemongo_bot/cell_workers/follow_path.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py index 5a36e2b02f..c7bdea3cbc 100644 --- a/pokemongo_bot/cell_workers/follow_path.py +++ b/pokemongo_bot/cell_workers/follow_path.py @@ -11,7 +11,7 @@ from pokemongo_bot.worker_result import WorkerResult from pgoapi.utilities import f2i from random import uniform -from utils import getSeconds +from utils import getSeconds, format_dist from datetime import datetime as dt, timedelta STATUS_MOVING = 0 @@ -26,6 +26,7 @@ def initialize(self): self.points = self.load_path() self.status = STATUS_MOVING self.loiter_end_time = 0 + self.distance_unit = self.bot.config.distance_unit if self.path_start_mode == 'closest': self.ptr = self.find_closest_point_idx(self.points) @@ -181,8 +182,8 @@ def work(self): data={ 'last_position': (last_lat, last_lng, last_alt), 'current_position': (lat, lng, alt), - 'distance': dist, - 'distance_unit': 'm' + 'distance': format_dist(dist,self.distance_unit), + 'distance_unit': self.distance_unit } ) From 64d06b2fc078c632e9421085d6b734455458507d Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Mon, 29 Aug 2016 16:16:14 -0700 Subject: [PATCH 5/6] Allow follow_path to use config's distance unit --- pokemongo_bot/cell_workers/follow_path.py | 3 ++- pokemongo_bot/cell_workers/utils.py | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py index c7bdea3cbc..34cdb46108 100644 --- a/pokemongo_bot/cell_workers/follow_path.py +++ b/pokemongo_bot/cell_workers/follow_path.py @@ -27,6 +27,7 @@ def initialize(self): self.status = STATUS_MOVING self.loiter_end_time = 0 self.distance_unit = self.bot.config.distance_unit + self.append_unit = False if self.path_start_mode == 'closest': self.ptr = self.find_closest_point_idx(self.points) @@ -182,7 +183,7 @@ def work(self): data={ 'last_position': (last_lat, last_lng, last_alt), 'current_position': (lat, lng, alt), - 'distance': format_dist(dist,self.distance_unit), + 'distance': format_dist(dist,self.distance_unit,self.append_unit), 'distance_unit': self.distance_unit } ) diff --git a/pokemongo_bot/cell_workers/utils.py b/pokemongo_bot/cell_workers/utils.py index 452176e687..a5dc6b8888 100644 --- a/pokemongo_bot/cell_workers/utils.py +++ b/pokemongo_bot/cell_workers/utils.py @@ -111,14 +111,17 @@ def convert(distance, from_unit, to_unit): # Converts units return distance * conversions[from_unit][to_unit] -def dist_to_str(distance, unit): - return '{:.2f}{}'.format(distance, unit) +def dist_to_str(distance, unit, append_unit = True): + if append_unit: + return '{:.2f}{}'.format(distance, unit) + else: + return '{:.2f}'.format(distance) -def format_dist(distance, unit): +def format_dist(distance, unit, append_unit = True): # Assumes that distance is in meters and converts it to the given unit, then a formatted string is returned # Ex: format_dist(1500, 'km') returns the string "1.5km" - return dist_to_str(convert(distance, 'm', unit), unit) + return dist_to_str(convert(distance, 'm', unit), unit, append_unit) def getSeconds(strTime): From 356bbe566448e80f15036e55ef520802400efa56 Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Tue, 30 Aug 2016 11:53:37 -0700 Subject: [PATCH 6/6] Hotfix for EvolvePokemon --- pokemongo_bot/cell_workers/evolve_pokemon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/cell_workers/evolve_pokemon.py b/pokemongo_bot/cell_workers/evolve_pokemon.py index 48ea4316ed..7822f4379e 100644 --- a/pokemongo_bot/cell_workers/evolve_pokemon.py +++ b/pokemongo_bot/cell_workers/evolve_pokemon.py @@ -49,7 +49,7 @@ def work(self): filtered_list = filter(lambda x: x.name in self.evolve_list, filtered_list) if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none': - filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list) + filtered_list = filter(lambda pokemon: pokemon.name not in self.donot_evolve_list, filtered_list) cache = {} for pokemon in filtered_list: