Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
[lat1,long1, lat2,long2],
[lat1,long1, lat2,long2]
],
"web_hooks": [
],
"stepsPerPassPerWorker": 300,
"scanDelay": 10.5
}
}
15 changes: 9 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
protobuf>=3.0.0a3
requests==2.10.0
s2sphere==0.2.4
future==0.15.2
geojson==1.3.3
geopy==1.11.0
gpsoauth==0.3.0
protobuf==3.0.0
protobuf-to-dict==0.1.0
geojson
six
xxhash
pycryptodomex==3.4.2
requests==2.10.0
s2sphere==0.2.4
six==1.10.0
xxhash==0.6.1
47 changes: 40 additions & 7 deletions track.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@

from pgoapi import pgoapi
from pgoapi import utilities as util
from pgoapi.exceptions import ServerSideRequestThrottlingException

from s2sphere import CellId, LatLng

import requests
from base64 import b64encode

pokes = []
spawns = []
Shash = {}
Expand All @@ -36,7 +40,7 @@ def withinWork(lat, lng):

def curSec():
return (60 * time.gmtime().tm_min) + time.gmtime().tm_sec

def timeDif(a,b):#timeDif of -1800 to +1800 secs
dif = a-b
if (dif < -1800):
Expand All @@ -56,7 +60,33 @@ def SbSearch(Slist, T):
else:
last = mp
return first

def sendToWebHook(data, p):
if not 'web_hooks' in config or len(config['web_hooks']) < 1:
return

payload = {
"type": "pokemon",
"message": {
"encounter_id": b64encode(str(p['encounter_id'])),
"spawnpoint_id": data["sid"],
"latitude": data["lat"],
"longitude": data["lng"],
"pokemon_id": data["pid"],
"disappear_time": (data["time"]+900000)/1000,
"last_modified_time": p["last_modified_timestamp_ms"],
"time_until_hidden_ms": p["time_till_hidden_ms"]
}
}

for url in config['web_hooks']:
try:
requests.post(url, json=push, timeout=(None, 1))
except requests.exceptions.ReadTimeout:
print 'Response timeout on webhook endpoint %s' % url
except requests.exceptions.RequestException as e:
print e

def worker(wid,Tthreads):
global spawns, Shash, going
#make own spawn list
Expand All @@ -66,10 +96,10 @@ def worker(wid,Tthreads):
print 'work list for worker {} is {} scans long'.format(wid,len(ownSpawns))
#find start position
pos = SbSearch(ownSpawns, (curSec()+3540)%3600)

api = pgoapi.PGoApi(provider=config['auth_service'], username=config['users'][wid]['username'], password=config['users'][wid]['password'], position_lat=0, position_lng=0, position_alt=0)
api.activate_signature(utils.get_encryption_lib_path())

while True:
#iterate over
while not paused:
Expand Down Expand Up @@ -119,10 +149,12 @@ def worker(wid,Tthreads):
timeSpawn = (curTime+(wild['time_till_hidden_ms']))-900000
if wild['spawn_point_id'] == sid:
gotit = True
pokes.append({'time':timeSpawn, 'sid':wild['spawn_point_id'], 'lat':wild['latitude'], 'lng':wild['longitude'], 'pid':wild['pokemon_data']['pokemon_id'], 'cell':CellId.from_lat_lng(LatLng.from_degrees(wild['latitude'], wild['longitude'])).to_token()})
curPoke = {'time':timeSpawn, 'sid':wild['spawn_point_id'], 'lat':wild['latitude'], 'lng':wild['longitude'], 'pid':wild['pokemon_data']['pokemon_id'], 'cell':CellId.from_lat_lng(LatLng.from_degrees(wild['latitude'], wild['longitude'])).to_token()}
pokes.append(curPoke)
sendToWebHook(curPoke, wild)
global Pfound
Pfound += 1

elif wild['spawn_point_id'] not in Shash:
print 'found new spawn'
gmSpawn = time.gmtime(timeSpawn//1000)
Expand All @@ -138,6 +170,7 @@ def worker(wid,Tthreads):
pos += 1
if timeDif(ownSpawns[pos]['time'],secSpawn)>0:#only bother to add it to the found pokes, if it has missed its scan window
pokeLog = {'time':timeSpawn, 'sid':wild['spawn_point_id'], 'lat':wild['latitude'], 'lng':wild['longitude'], 'pid':wild['pokemon_data']['pokemon_id'], 'cell':CellId.from_lat_lng(LatLng.from_degrees(wild['latitude'], wild['longitude'])).to_token()}
sendToWebHook(pokeLog, wild)
pokes.append(pokeLog)
Pfound += 1
else:
Expand Down Expand Up @@ -234,10 +267,10 @@ def main():
f = open('pokes.json','w')
json.dump(pokes,f)
f.close()

with open('spawns.json','w') as file:
json.dump(spawns,file)
file.close()

if __name__ == '__main__':
main()
main()