diff --git a/README.md b/README.md index 77c4a53af8..b50c641706 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ # PokemonGo-Bot The Pokemon Go Bot, baking with community. - +## Help Needed on [Desktop Version](https://github.com/PokemonGoF/PokemonGo-Bot-Desktop) ## Project Chat We use [Slack](https://slack.com) as a web chat. [Click here to join the chat!](https://pokemongo-bot.herokuapp.com) ## Breaking Changes @@ -18,7 +18,7 @@ You need modify config.json (config.json.example for example) then pokecli.py -- Please clean up your old clone if you have issue, and following the [install instruction](https://github.com/PokemonGoF/PokemonGo-Bot#installation). ## About dev/master Branch -Dev branch has most up to date feature and even everyone handle the part well, still, will have broken changes. Your test contribute and PR for fix are warm welcome. +Dev branch has the most up-to-date features, but be aware that there might be some broken changes. Your contribution and PR for fixes are warm welcome. Master branch is the stable branch. No PR on master branch to keep things easier. ## Table of Contents @@ -45,7 +45,7 @@ No PR on master branch to keep things easier. * Limit the step to farm specific area for pokestops * Use the ball you have to catch, don't if you don't have * Rudimentary IV Functionality filter - * Auto switch mode(Full of item then catch, no ball useable then farm) + * Auto switch mode (Full of item then catch, no ball useable then farm) * Ignore certain pokemon filter * Use superior ball types when necessary * When out of normal pokeballs, use the next type of ball unless there are less than 10 of that type, in which case switch to farm mode @@ -82,10 +82,10 @@ No PR on master branch to keep things easier. - Linux: `apt-get install python-protobuf` ### Note on branch -Please keep in mind that master is not always up to date whereas 'dev' is. In the installation note below change `master` to `dev` if you want to get the latest version. +Please keep in mind that master is not always up-to-date whereas 'dev' is. In the installation note below change `master` to `dev` if you want to get and use the latest version. ### Installation Linux -(change master to dev for the newer version) +(change master to dev for the latest version) ``` $ git clone -b master https://github.com/PokemonGoF/PokemonGo-Bot @@ -96,7 +96,7 @@ $ git submodule update ``` ### Installation Mac -(change master to dev for the newer version) +(change master to dev for the latest version) ``` $ git clone -b master https://github.com/PokemonGoF/PokemonGo-Bot @@ -109,7 +109,7 @@ $ git submodule update ``` ### Installation Windows -(change master to dev for the newer version) +(change master to dev for the latest version) On Windows, you will need to install PyYaml through the installer and not through requirements.txt. @@ -128,7 +128,7 @@ $ pip install PyYAML-3.11-cp27-cp27m-win32.whl // (replace PyYAML-3.11-cp27-cp27m-win32.whl with PyYAML-3.11-cp27-cp27m-win_amd64.whl ``` -After this, just do : +After this, just do: ``` $ git clone -b master https://github.com/PokemonGoF/PokemonGo-Bot @@ -164,20 +164,20 @@ This project uses Google Maps. There's one map coupled with the project, but as 6. After the code done, will update here how to replace. ### Python possible bug -If you encounter problems with the module `ssl` and it function `_create_unverified_context`. Just comment it. (Solution available in Python 2.7.11) -To do it follow instruction below : +If you encounter problems with the module `ssl` and it's function `_create_unverified_context`, just comment it. (Solution available in Python 2.7.11) +In order to comment out the function and the module, please follow the instructions below: - edit `pokecli.py` - put `#` before `if` (line 43) and `ssl` (line 44) - save it -Please keep in mind that this fix is necessary only if your python version don't have the `_create_unverified_context` argument in ssl module. +Please keep in mind that this fix is only necessary if your python version don't have the `_create_unverified_context` argument in the ssl module. ## Update To update your project do: `git pull` in the project folder -## Usage (up to date) +## Usage (up-to-date) 1/ copy `config.json.example` to `config.json` and `release_config.json.example` to `release_config.json`. - 2/ Edit `config.json` and replace `auth_service`, `username`, `password`, `location` and `gmapkey` with your parameters (others keys are optional, check `Advance Configuration` below) + 2/ Edit `config.json` and replace `auth_service`, `username`, `password`, `location` and `gmapkey` with your parameters (other keys are optional, check `Advance Configuration` below) ## Advance Configuration - `max_steps` : @@ -189,7 +189,7 @@ To update your project do: `git pull` in the project folder - `location_cache` : - `distance_unit` : - `item_filter` : -- `evolve_all` : Set to true to evolve pokemon if possible +- `evolve_all` : Set to true to evolve pokemons if possible ### Evolve All Configuration By setting the `evolve_all` attribute in config.json, you can instruct the bot to automatically @@ -264,7 +264,7 @@ Try to generate an [app password](!https://support.google.com/accounts/answer/18 ``` -p "" ``` -This error is mostly occurs for those who using 2 factor authentication but either way for the purpose of security would be nice to have a separate password for the bot app. +This error mostly occurs for those who are using 2 factor authentication, but either way, for the purpose of security it would be nice to have a separate password for the bot app. ### FLEE @@ -282,7 +282,7 @@ Create the following filter ``` ./data/catch-ignore.yml ``` -Its a yaml file with a list of names so make it look like +It's a yaml file with a list of names so make it look like ``` ignore: - Pidgey @@ -337,6 +337,7 @@ If using multiple usernames format like this: * riberod07 * th3w4y * Leaklessgfy + * Anziclone ------- ## Credits diff --git a/pokecli.py b/pokecli.py index 07cf746c06..963b96bf20 100755 --- a/pokecli.py +++ b/pokecli.py @@ -48,6 +48,7 @@ def init_config(): parser = argparse.ArgumentParser() config_file = "config.json" release_config_json = "release_config.json" + web_dir = "web" # If config file exists, load variables from json load = {} @@ -172,15 +173,12 @@ def init_config(): with open(release_config_json) as data: config.release_config.update(json.load(data)) - web_index = 'web/index.html' - if config.gmapkey and os.path.isfile(web_index): - find_url = 'https:\/\/maps.googleapis.com\/maps\/api\/js\?key=\S*' - replace_url = "https://maps.googleapis.com/maps/api/js?key=%s&callback=initMap\"" - #Someone make this pretty! (Efficient) - with open(web_index, "r+") as sources: # r+ is read + write - lines = sources.readlines() - for line in lines: - sources.write(re.sub(r"%s" % find_url, replace_url % config.gmapkey, line)) + # create web dir if not exists + try: + os.makedirs(web_dir) + except OSError: + if not os.path.isdir(web_dir): + raise if config.evolve_all: config.evolve_all = [str(pokemon_name) for pokemon_name in config.evolve_all.split(',')] diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index d6df1a38d7..0c3acd1d8a 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import os import logging import googlemaps import json @@ -57,15 +56,14 @@ def work_on_cell(self, cell, position, include_fort_on_path): lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude'])) user_web_catchable = 'web/catchable-%s.json' % (self.config.username) - if os.path.isfile(user_web_catchable): # only write to file if it exists - for pokemon in cell['catchable_pokemons']: - with open(user_web_catchable, 'w') as outfile: - json.dump(pokemon, outfile) + for pokemon in cell['catchable_pokemons']: + with open(user_web_catchable, 'w') as outfile: + json.dump(pokemon, outfile) - if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS: - break - with open(user_web_catchable, 'w') as outfile: - json.dump({}, outfile) + if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS: + break + with open(user_web_catchable, 'w') as outfile: + json.dump({}, outfile) if (self.config.mode == "all" or self.config.mode == "poke" ) and 'wild_pokemons' in cell and len(cell['wild_pokemons']) > 0: @@ -237,9 +235,8 @@ def pokeball_inventory(self): 'inventory_delta']['inventory_items'] user_web_inventory = 'web/inventory-%s.json' % (self.config.username) - if os.path.isfile(user_web_inventory): - with open(user_web_inventory, 'w') as outfile: - json.dump(inventory_dict, outfile) + with open(user_web_inventory, 'w') as outfile: + json.dump(inventory_dict, outfile) # get player balls stock # ---------------------- diff --git a/pokemongo_bot/cell_workers/initial_transfer_worker.py b/pokemongo_bot/cell_workers/initial_transfer_worker.py index f09b91e07c..026e79ddaa 100644 --- a/pokemongo_bot/cell_workers/initial_transfer_worker.py +++ b/pokemongo_bot/cell_workers/initial_transfer_worker.py @@ -1,5 +1,4 @@ import json -import os from pokemongo_bot.human_behaviour import sleep from pokemongo_bot import logger @@ -51,9 +50,8 @@ def _initial_transfer_get_groups(self): 'inventory_delta']['inventory_items'] user_web_inventory = 'web/inventory-%s.json' % (self.config.username) - if os.path.isfile(user_web_inventory): - with open(user_web_inventory, 'w') as outfile: - json.dump(inventory_dict, outfile) + with open(user_web_inventory, 'w') as outfile: + json.dump(inventory_dict, outfile) for pokemon in inventory_dict: try: diff --git a/pokemongo_bot/stepper.py b/pokemongo_bot/stepper.py index fda5e63fb8..0c837b2215 100644 --- a/pokemongo_bot/stepper.py +++ b/pokemongo_bot/stepper.py @@ -4,6 +4,7 @@ import json import time import pprint +import sys from math import ceil from s2sphere import CellId, LatLng @@ -74,6 +75,7 @@ def _walk_to(self, speed, lat, lng, alt): if steps != 0: dLat = (lat - i2f(self.api._position_lat)) / steps dLng = (lng - i2f(self.api._position_lng)) / steps + bar_length = 40 for i in range(intSteps): cLat = i2f(self.api._position_lat) + \ @@ -82,6 +84,11 @@ def _walk_to(self, speed, lat, lng, alt): dLng + random_lat_long_delta() self.api.set_position(cLat, cLng, alt) self.bot.heartbeat() + percent = float(i) / intSteps + hashes = '#' * int(round(percent * bar_length)) + spaces = ' ' * (bar_length - len(hashes)) + sys.stdout.write("\r[#] Percent: [{0}] {1}%".format(hashes + spaces, int(round(percent * 100)))) + sys.stdout.flush() sleep(1) # sleep one second plus a random delta self._work_at_position( i2f(self.api._position_lat), i2f(self.api._position_lng),