Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update index.html #20

Merged
merged 6 commits into from
Jul 29, 2016
Merged
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Edit the 'usersettings.json' file in the res subfolder to your liking. Don't worry, if you don't understand every setting, some are for more specific uses.
* 'standard_coordinates' and the first 'profile' have to be edited and if you want the map functionality the 'api_key' setting as well
* 'pip install -r requirements.txt' or if that fails 'pip install --user -r requirements.txt'
* 'pip install pushbullet.py' to install the pushbullet API
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be added to requirements.txt instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to do that, but I wasn't sure how.

* You will need an API key from https://www.pushbullet.com/#settings
* Make sure to add the Pokemon ID's you want to be notifuied about to the configuration file
* 'python main0.py' to run the program

* 'python -m SimpleHTTPServer 8000' to run the local map server and make it accessible from your browser
Expand Down
14 changes: 10 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@
function initSite() {
getFile("res/usersettings.json", false, function(tsettings) {
var settings=JSON.parse(tsettings);

LAT_C=settings['standard_coordinates']['lat'];
LNG_C=settings['standard_coordinates']['lng'];
var centralized=settings['unique_coordinates'];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to create a new variable here, just use it directly in the next line.

if (centralized==false){
LAT_C=settings['standard_coordinates']['lat'];
LNG_C=settings['standard_coordinates']['lng'];
}
else{
LAT_C=settings['profiles']['0']['coordinates']['lat'];
LNG_C=settings['profiles']['0']['coordinates']['lng'];
}
LANGUAGE=settings['language'];
excludeIDs=settings['exclude_ids'];
scalesize = Math.ceil(72*settings['icon_scalefactor']);
Expand All @@ -189,4 +195,4 @@
</script>


</body></html>
</body></html>
25 changes: 18 additions & 7 deletions main0.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import POGOProtos.Data_pb2
import POGOProtos.Enums_pb2
import POGOProtos.Inventory_pb2
import POGOProtos.Inventory_pb2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doubled? :P

import POGOProtos.Map_pb2
import POGOProtos.Settings_pb2
import POGOProtos.Networking
Expand All @@ -15,12 +16,13 @@
import POGOProtos.Networking.Responses_pb2
import POGOProtos.Networking.Requests
import POGOProtos.Networking.Requests.Messages_pb2

import pushbullet
Copy link
Owner

@seikur0 seikur0 Jul 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant, since you do the second import below

import os.path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you import this? It's not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the code from the comments on your reddit page(with some customizing). I assumed it was for the people who installed the PB API directly.

import time
from datetime import datetime
import sys
import math

from pushbullet import Pushbullet
from s2sphere import CellId, LatLng
from gpsoauth import perform_master_login, perform_oauth
from shutil import move
Expand Down Expand Up @@ -93,7 +95,7 @@ def getNeighbors():
access_token = None
response = {}
r = None

pb = None

SETTINGS_FILE='res/usersettings.json'

Expand All @@ -107,7 +109,8 @@ def do_settings():
global HEX_NUM
global interval
global F_LIMIT

global POKEMONS_PUSH
global pb
parser = argparse.ArgumentParser()
parser.add_argument("-id", "--id", help="worker id")
parser.add_argument("-r", "--range", help="scan range")
Expand Down Expand Up @@ -205,7 +208,14 @@ def do_settings():
F_LIMIT=int(allsettings['backup_size']*1024*1024)
if F_LIMIT==0:
F_LIMIT=9223372036854775807

PBKEY = allsettings['PB_ApiKey']
if pb is None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check, if that's None, since it always is. I only check the command line arguments for that, since they are allowed to overwrite settings. Also I'll add another boolean settings to make pushbullet optional.

pb = Pushbullet(PBKEY)
POKEMONS_PUSH=allsettings['Pokemon_to_Push']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transform this into a set, they're more efficient with the in operator.





def prune_data():
# prune despawned pokemon
cur_time = int(time.time())
Expand Down Expand Up @@ -440,7 +450,7 @@ def get_profile(access_token, api, useauth, *reqq):

retry_after=0.26
while newResponse.status_code not in [1,2,53,102]: #1 for hearbeat, 2 for profile authorization, 53 for api endpoint, 52 for error, 102 session token invalid
print('[-] Response error, status code: {}, retrying in {} seconds'.format(newResponse.status_code,retry_after))
#print('[-] Response error, status code: {}, retrying in {} seconds'.format(newResponse.status_code,retry_after))
time.sleep(retry_after)
retry_after=min(retry_after*2,MAXWAIT)
newResponse = api_req(api, access_token, req, useauth = useauth)
Expand Down Expand Up @@ -630,7 +640,8 @@ def main():

f.write('{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format(pokemons[wild.pokemon_data.pokemon_id],wild.pokemon_data.pokemon_id,spawnIDint,wild.latitude,wild.longitude,(wild.last_modified_timestamp_ms+wild.time_till_hidden_ms)/1000.0-900.0,wild.last_modified_timestamp_ms/1000.0,org_tth/1000.0,wild.encounter_id))
add_pokemon(wild.pokemon_data.pokemon_id,spawnIDint, wild.latitude, wild.longitude, int((wild.last_modified_timestamp_ms+wild.time_till_hidden_ms)/1000.0))

if wild.pokemon_data.pokemon_id in POKEMONS_PUSH:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will only execute, when pushbullet is active.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works this way because the default is 0 in the config?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to say, that I want it like that. Look at how I changed that in the update.

push = pb.push_link("Pokemon {} found! Timer {}".format(pokemons[wild.pokemon_data.pokemon_id],int(wild.time_till_hidden_ms/1000.0)), 'http://www.google.com/maps/place/{},{}'.format(wild.latitude,wild.longitude))
if LOGGING:
other = LatLng.from_degrees(wild.latitude, wild.longitude)
diff = other - origin
Expand Down
9 changes: 7 additions & 2 deletions res/usersettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,10 @@
"alt": 0
}
}
]
}
],

"_comment15": "Set your Pushbullet API key and what pokemon you wish to be notified of here. Format is [1,2,3,76,138]",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll shift that above the profiles, nobdy will see it here.

"PB_ApiKey": "YOUR_PB_API_KEY",
"Pokemon_to_Push": [0]

}