Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Fixed Notifications + PB send to channel+ clickable link (#32)
Browse files Browse the repository at this point in the history
* Fixed Notifications

* Fixed Notifications

* Updated ability to send to channel in pushbullet!
  • Loading branch information
malosaa authored and jxmorris12 committed Jul 24, 2016
1 parent b211daa commit 20a51c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
14 changes: 9 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,13 +725,17 @@ def process_step(args, api_endpoint, access_token, profile_response,
"name": pokename
}

pokemons[poke.SpawnPointId] = pokemon_obj

print "Pokemon :", pokemon_obj



#change
print "Pokemon :", pokemon_obj
if poke.SpawnPointId not in pokemons:
notifier.pokemon_found(pokemon_obj)

pokemons[poke.SpawnPointId] = pokemon_obj

notifier.pokemon_found(pokemon_obj)
#change

def clear_stale_pokemons():
current_time = time.time()

Expand Down
15 changes: 11 additions & 4 deletions notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ def init():
def _str(s):
return s.encode('utf-8').strip()





# Notify user for discovered Pokemon
def pokemon_found(pokemon):
#pushbulley channel
# Or retrieve a channel by its channel_tag. Note that an InvalidKeyError is raised if the channel_tag does not exist
my_channel = pushbullet_client.get_channel('CHANNELNAME HERE')
# get name
pokename = _str(pokemon["name"]).lower()
# check array
Expand All @@ -57,11 +64,11 @@ def pokemon_found(pokemon):
latLon = '{},{}'.format(repr(pokemon["lat"]), repr(pokemon["lng"]))
google_maps_link = 'http://maps.google.com/maps/place/{}/@{},{}z'.format(latLon, latLon, 20)

notification_text = "Pokemon Finder found " + _str(pokemon["name"]) + "!"
notification_text = "Pokemon Found " + _str(pokemon["name"]) + "!"
disappear_time = str(datetime.fromtimestamp(pokemon["disappear_time"]).strftime("%I:%M%p").lstrip('0'))+")"
location_text = _str(pokemon["name"]) + " will be available until " + disappear_time + "."

push = pushbullet_client.push_link(notification_text, google_maps_link, body=location_text)
location_text = "Location : " + google_maps_link + ". " + _str(pokemon["name"]) + " Available till " + disappear_time + "."
push = pushbullet_client.push_link(notification_text, google_maps_link, body=location_text, channel=my_channel)
#push = pushbullet_client.push_link(notification_text, google_maps_link, body=location_text)



Expand Down

0 comments on commit 20a51c3

Please sign in to comment.