Skip to content

Commit

Permalink
Merge pull request #2 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Merged latest
  • Loading branch information
Shoh authored Jul 23, 2016
2 parents 9f1e75f + 3937b50 commit 704ef8f
Show file tree
Hide file tree
Showing 13 changed files with 426 additions and 237 deletions.
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var/
*.manifest
*.spec

# Eclipse Users
.project
.pydevproject
.settings/


# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down Expand Up @@ -90,16 +96,21 @@ ENV/

# Personal load details
config.json
location.json
src/
info.json
inventory.json
pokedex.json
web/catchable.json
web/catchable-*.json
web/location-*.json
web/location.json
web/userdata.js
data/last-location*.json
data/catch-ignore.yml

# ignore Pycharm config
.idea

# personal docker-compose
docker-compose.yml
docker-compose.yml
web/userdata.js
116 changes: 88 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
# PokemonGo-Bot - a pokemon script that can catch pokemons and spin the pokestops.
<p align="center">
<a href="">
<img alt="Logo" src="https://www.brooklinelibrary.org/wp-content/uploads/2016/07/2000px-Pok%C3%A9_Ball.svg_-1.png" width="100">
</a>
</p>

## Project chat
<p align="center">
<a href="https://pokemongo-bot.herokuapp.com/"><img alt="Slack" src="https://pokemongo-bot.herokuapp.com/badge.svg"></a>
</p>

[![Slack Status](https://pokemongo-bot.herokuapp.com/badge.svg)](https://pokemongo-bot.herokuapp.com)
# PokemonGo-Bot
A python script for __catching pokemons__ and __spin pokestops__ on PokemonGo.


## Project Chat
We use [Slack](https://slack.com) as a web chat. [Click here to join the chat!](https://pokemongo-bot.herokuapp.com)

## Features:
* Search Fort(Spin Pokestop)
## Table of Contents
- [Project Chat](#project-chat)
- [Features](#features)
- [TODO List](#todo-list)
- __Installation__
- [Requirements](#requirements)
- [Mac](#installation-mac)
- [Linux](#installation-linux)
- [Windows](#installation-windows)
- [Develop PokemonGo-Bot](develop-pokemonGo-bot)
- [Usage](#usage)
- [FAQ](#faq)
- [Credits](#credits)
- [Donation](#donation)

## Features
* Search Fort (Spin Pokestop)
* Catch Pokemon
* Release low cp pokemon
* Walking as you
* Use the ball you have to catch, don't if you don't have
* Rudimentary IV Functionality filter
* Rudimentary IV Functionality filter (Need verify)
* Auto switch mode(Full of item then catch, no ball useable then farm)
* Ignore certain pokemon filter

## To-Do:
## TODO List

- [ ] Standalone Desktop APP
- [x] Google Map API key setup (Readme update needed)
- [ ] Show all objects on map
Expand All @@ -35,44 +60,63 @@ We use [Slack](https://slack.com) as a web chat. [Click here to join the chat!](
### Requirements (click each one for install guide)

- [Python 2.7.x](http://docs.python-guide.org/en/latest/starting/installation/)
- [pip](https://pip.pypa.io/en/stable/installing/)
- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [virtualenv](https://virtualenv.pypa.io/en/stable/installation/)
- [protobuf 3](https://github.com/google/protobuf) (OS Dependent, see below)
- [virtualenv](https://virtualenv.pypa.io/en/stable/installation/) (Optional)
- [docker](https://docs.docker.com/engine/installation/) (Optional)
- [protobuf 3](https://github.com/google/protobuf) (OS Dependent, see below)

### Protobuf 3 installation

- OS X: `brew update && brew install --devel protobuf`
- Windows: Download protobuf 3.0: [here](https://github.com/google/protobuf/releases/download/v3.0.0-beta-4/protoc-3.0.0-beta-4-win32.zip) and unzip `bin/protoc.exe` into a folder in your PATH.
- Linux: `apt-get install python-protobuf`

### Installation

### Installation Linux

```
$ git clone -b master https://github.com/PokemonGoF/PokemonGo-Bot
$ cd PokemonGo-Bot
$ pip install -r requirements.txt
```

### Installation Mac

```
$ git clone -b master https://github.com/PokemonGoF/PokemonGo-Bot
$ cd PokemonGo-Bot
$ virtualenv .
$ source bin/activate
$ pip install -r requirements.txt
$ pip install -r requirements.txt
```

### Installation Windows

###### Windows Note
On Windows, you will need to install PyYaml through the [installer](http://pyyaml.org/wiki/PyYAML) and not through requirements.txt.

Windows 10:
Go to [this](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyyaml) page and download: PyYAML-3.11-cp27-cp27m-win32.whl
(If running 64-bit python or if you get a 'not a supported wheel on this platform' error, download the 64 bit version instead: PyYAML-3.11-cp27-cp27m-win_amd64.whl )

$ cd download-directory
$ 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 if you needed to download the 64-bit version)

(If running 64-bit python or if you get a 'not a supported wheel on this platform' error,
download the 64 bit version instead: PyYAML-3.11-cp27-cp27m-win_amd64.whl )
```
$ cd download-directory
$ 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
// if you needed to download the 64-bit version)
```
### Develop PokemonGo-Bot

```
$ git clone -b dev https://github.com/PokemonGoF/PokemonGo-Bot
$ cd PokemonGo-Bot
$ virtualenv .
$ source bin/activate
$ pip install -r requirements.txt
```

### Google Maps API (In Development)
### Google Maps API (in development)

Google Maps API: a brief guide to your own key

Expand All @@ -86,23 +130,22 @@ 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.

## Usage
usage: pokecli.py [-h] -a AUTH_SERVICE -u USERNAME -p PASSWORD -l LOCATION [-w] [-d] [-t] [-c] [-m]
usage: pokecli.py [-h] -a AUTH_SERVICE -u USERNAME -p PASSWORD -l LOCATION [-lc] [-c] [-m] [-w] [--distance_unit] [--initial-transfer] [--maxsteps] [-iv] [-d] [-t]

optional arguments:
-h, --help show this help message and exit
-a AUTH_SERVICE, --auth_service AUTH_SERVICE Auth Service ('ptc' or 'google')
-u USERNAME, --username USERNAME Username
-p PASSWORD, --password PASSWORD Password
-l LOCATION, --location LOCATION Location (Address or 'xx.yyyy,zz.ttttt')
-lc, --use-location-cache Bot will start at last known location
-w SPEED, --walk SPEED Walk instead of teleport with given speed (meters per second max 4.16 because of walking end on 15km/h)
-m MODE, --mode MODE Set farming Mode for the bot ('all', 'poke', 'farm')
--maxsteps MAX_STEP Set the steps around your initial location(DEFAULT 5 mean 25 cells around
your location)
--initial-transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release.
-lc, --location_cache Bot will start at last known location
-c CP, --cp Set the CP to transfer or lower (eg. 100 will transfer CP0-99)
-m MODE, --mode MODE Set farming Mode for the bot ('all', 'poke', 'farm')
-w SPEED, --walk SPEED Walk instead of teleport with given speed (meters per second max 4.16 because of walking end on 15km/h)
-du, --distance_unit UNIT Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)
-it, --initial_transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release.
-ms, --max_steps MAX_STEP Set the steps around your initial location (DEFAULT 5 mean 25 cells around your location)
-iv IV, --pokemon_potential Set the ratio for the IV values to transfer (eg. 0.8 will transfer a pokemon with IV 0.5)
--distance_unit UNIT Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)
-d, --debug Debug Mode
-t, --test Only parse the specified location

Expand Down Expand Up @@ -153,6 +196,17 @@ Quick Tip: When using this script, use a Lucky egg to double the XP for 30 mins.
### How can I not collect certain pokemon
You don't want to collect common pokemon once you hit a certain level. It will
slow down leveling but you won't fill up either.
### How do I use the map??
You can either view the map via opening the html file, or by serving it with SimpleHTTPServer (runs on localhost:8000)
To use SimpleHTTPServer:
```$ python -m SimpleHTTPServer [port]```
The default port is 8080, you can change that by giving a port number.
Anything above port 1000 does not require root.
You will need to set your username(s) in the userdata.js file before opening:
Copy userdata.js.example to userdata.js and edit with your favorite text editor.
put your username in the quotes instead of "username"
If using multiple usernames format like this:
```var users = ["username1","username2"];```

Create the following filter

Expand Down Expand Up @@ -202,9 +256,13 @@ To install the pgoapi use `pip install -e git://github.com/tejado/pgoapi.git#egg
* CapCap
* mzupan
* namlehong
* gnekic(GeXx)
* luizperes
* brantje
* VirtualSatai
* dmateusp

## Credits
### The works are based on the Pokemon Go API
[tejado](https://github.com/tejado) many thanks for the API
[Mila432](https://github.com/Mila432/Pokemon_Go_API) for the login secrets
[elliottcarlson](https://github.com/elliottcarlson) for the Google Auth PR
Expand All @@ -216,4 +274,6 @@ To install the pgoapi use `pip install -e git://github.com/tejado/pgoapi.git#egg

Bitcoin Address: 1PJMCx9NNQRasQYaa4MMff9yyNFffhHgLu

[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WQUXDC54W6EVY)
<p align="center">
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WQUXDC54W6EVY"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif"></a>
</p>
19 changes: 11 additions & 8 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"auth_service": "google",
"username": "example@gmail.com",
"password": "password11!!",
"location": "New York",
"username": "YOURACCOUNT@gmail.com",
"password": "YOURPASSWORD",
"location": "SOME LOCATION",
"cp": 100,
"gmapkey": "CHANGME",
"maxsteps": 100,
"gmapkey": "AGMAPAPIKEY",
"max_steps": 50,
"mode": "all",
"walk": 4.16,
"debug": true,
"test": false
"debug": false,
"test": false,
"initial_transfer": false,
"pokemon_potential": 0.70,
"location_cache": true,
"distance_unit": "km"
}

20 changes: 9 additions & 11 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,18 @@ def init_config():
parser.add_argument("-u", "--username", help="Username")
parser.add_argument("-p", "--password", help="Password")
parser.add_argument("-l", "--location", help="Location")
parser.add_argument("-lc", "--use-location-cache", help="Bot will start at last known location", action='store_true', default=False, dest='location_cache')
parser.add_argument("-lc", "--location_cache", help="Bot will start at last known location", type=bool, default=False)
parser.add_argument("-m", "--mode", help="Farming Mode", type=str, default="all")
parser.add_argument("-w", "--walk", help="Walk instead of teleport with given speed (meters per second, e.g. 2.5)", type=float, default=2.5)
parser.add_argument("-c", "--cp",help="Set CP less than to transfer(DEFAULT 100)",type=int,default=100)
parser.add_argument("-iv", "--pokemon_potential",help="Set IV ratio less than to transfer(DEFAULT 0.80)",type=float,default=0.80)
parser.add_argument("-k", "--gmapkey",help="Set Google Maps API KEY",type=str,default=None)
parser.add_argument("--maxsteps",help="Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",type=int,default=5)
parser.add_argument("--initial-transfer", help="Transfer all pokemon with same ID on bot start, except pokemon with highest CP. It works with -c", action='store_true', dest='initial_transfer')
parser.add_argument("-d", "--debug", help="Debug Mode", action='store_true')
parser.add_argument("-t", "--test", help="Only parse the specified location", action='store_true')
parser.add_argument("--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="m")
parser.set_defaults(DEBUG=False, TEST=False)
parser.add_argument("-k", "--gmapkey",help="Set Google Maps API KEY",type=str, default=None)
parser.add_argument("-ms","--max_steps",help="Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",type=int,default=50)
parser.add_argument("-it", "--initial_transfer", help="Transfer all pokemon with same ID on bot start, except pokemon with highest CP. It works with -c", type=bool, default=False)
parser.add_argument("-d", "--debug", help="Debug Mode", type=bool, default=False)
parser.add_argument("-t", "--test", help="Only parse the specified location", type=bool, default=False)
parser.add_argument("-du","--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="km")
config = parser.parse_args()

if not config.username and not 'username' in load:
config.username = raw_input("Username: ")
if not config.password and not 'password' in load:
Expand All @@ -89,9 +87,9 @@ def init_config():
return None

if not config.location and not config.location_cache in load:
log.error("Needs either --use-location-cache or --location.")
logging.error("Needs either --use-location-cache or --location.")
return None

print(config)
return config

def main():
Expand Down
10 changes: 6 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ def work_on_cell(self, cell, position, include_fort_on_path):
with open('web/catchable-%s.json' % (self.config.username), 'w') as outfile:
json.dump(pokemon, outfile)
worker = PokemonCatchWorker(pokemon, self)
worker.work()
if worker.work() == -1:
break;
with open('web/catchable-%s.json' % (self.config.username), '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:
# Sort all by distance from current pos- eventually this should build graph & A* it
cell['wild_pokemons'].sort(key=lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude']))
for pokemon in cell['wild_pokemons']:
worker = PokemonCatchWorker(pokemon, self)
worker.work()
if worker.work() == -1:
break;
if (self.config.mode == "all" or self.config.mode == "farm") and include_fort_on_path:
if 'forts' in cell:
# Only include those with a lat/long
Expand Down Expand Up @@ -280,7 +282,7 @@ def _set_starting_position(self):
try:
#
# save location flag used to pull the last known location from the location.json
with open('location.json') as f:
with open('data/last-location-%s.json' % (self.config.username)) as f:
location_json = json.load(f)

self.position = (location_json['lat'], location_json['lng'], 0.0)
Expand Down Expand Up @@ -308,7 +310,7 @@ def _set_starting_position(self):

def _get_pos_by_name(self, location_name):
geolocator = GoogleV3(api_key=self.config.gmapkey)
loc = geolocator.geocode(location_name)
loc = geolocator.geocode(location_name, timeout=10)

#self.log.info('Your given location: %s', loc.address.encode('utf-8'))
#self.log.info('lat/long/alt: %s %s %s', loc.latitude, loc.longitude, loc.altitude)
Expand Down
4 changes: 2 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def work(self):
print_red('[x] Out of pokeballs, switching to farming mode...')
# Begin searching for pokestops.
self.config.mode='farm'
break
return -1

print('[x] Using {}...'.format(self.item_list[str(pokeball)]))

Expand Down Expand Up @@ -106,7 +106,7 @@ def work(self):
pokemon_to_transfer = list(Set(id_list2) - Set(id_list1))
if len(pokemon_to_transfer) == 0:
raise RuntimeError('Trying to transfer 0 pokemons!')
self.transfer_pokemon(pokemon_to_transfer)
self.transfer_pokemon(pokemon_to_transfer[0])
print_green('[#] {} has been exchanged for candy!'.format(pokemon_name))
else:
print_green('[x] Captured {}! [CP {}]'.format(pokemon_name, cp))
Expand Down
13 changes: 9 additions & 4 deletions pokemongo_bot/cell_workers/seen_fort_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def work(self):
dist = distance(self.position[0], self.position[1], lat, lng)

#print('[#] Found fort {} at distance {}m'.format(fortID, dist))
print(' [#] Found fort {} at distance {}'.format(fortID, format_dist(dist, unit)))
print('[#] Found fort {} at distance {}'.format(fortID, format_dist(dist, unit)))

if dist > 10:
print('[#] Need to move closer to Pokestop')
Expand All @@ -45,11 +45,16 @@ def work(self):

self.api.fort_details(fort_id=self.fort['id'], latitude=lat, longitude=lng)
response_dict = self.api.call()
fort_details = response_dict['responses']['FORT_DETAILS']
fort_name = fort_details['name'].encode('utf8', 'replace')
if 'responses' in response_dict \
and'FORT_DETAILS' in response_dict['responses'] \
and 'name' in response_dict['responses']['FORT_DETAILS']:
fort_details = response_dict['responses']['FORT_DETAILS']
fort_name = fort_details['name'].encode('utf8', 'replace')
else:
fort_name = 'Unknown'
print_yellow('[#] Now at Pokestop: ' + fort_name + ' - Spinning...')
sleep(2)
self.api.fort_search(fort_id=self.fort['id'], fort_latitude=lat, fort_longitude=lng, player_latitude=f2i(position[0]), player_longitude=f2i(position[1]))
self.api.fort_search(fort_id=self.fort['id'], fort_latitude=lat, fort_longitude=lng, player_latitude=f2i(self.position[0]), player_longitude=f2i(self.position[1]))
response_dict = self.api.call()
if 'responses' in response_dict and \
'FORT_SEARCH' in response_dict['responses']:
Expand Down
Loading

0 comments on commit 704ef8f

Please sign in to comment.