Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import json
- from pushbullet import Pushbullet
- from datetime import datetime
- import sys
- # Fixes the encoding of the male/female symbol
- reload(sys)
- sys.setdefaultencoding('utf8')
- pushbullet_client = None
- wanted_pokemon = list()
- with open('locales/pokemon.en.json') as f:
- pokemon_names = json.load(f)
- # Initialize object
- def init():
- global pushbullet_client, wanted_pokemon
- # load pushbullet key
- wanted_pokemon = ["Ivysaur", "Venusaur", "Charmeleon",
- "Charizard", "Wartortle", "Blastoise", "Butterfree", "Beedrill", "Arbok",
- "Raichu", "Sandslash", "Nidorina", "Nidoqueen", "Nidorino", "Nidoking", "Clefable",
- "Ninetales", "Wigglytuff", "Gloom", "Vileplume", "Parasect", "Venomoth",
- "Dugtrio", "Golduck", "Primeape", "Growlithe", "Arcanine", "Poliwrath", "Kadabra",
- "Alakazam", "Machoke", "Machamp", "Weepinbell", "Victreebel", "Tentacruel", "Graveler",
- "Golem", "Rapidash", "Slowbro", "Magneton", "Farfetch'd", "Dodrio", "Dewgong", "Muk",
- "Cloyster", "Haunter", "Gengar", "Exeggcute", "Exeggutor", "Marowak",
- "Weezing", "Rhydon", "Chansey", "Kangaskhan", "Seadra",
- "Mr. Mime", "Scyther", "Electabuzz", "Magmar", "Pinsir", "Tauros",
- "Gyarados", "Lapras", "Ditto", "Vaporeon", "Jolteon", "Flareon", "Porygon",
- "Omanyte", "Omastar", "Kabuto", "Kabutops", "Aerodactyl", "Snorlax", "Articuno",
- "Zapdos", "Moltres", "Dragonair", "Dragonite", "Mewtwo", "Mew" ]
- api_key = "PUSH BULLET API KEY HERE" #get one by setting up an account through pushbullet.com
- if api_key:
- pushbullet_client = Pushbullet(api_key)
- # Safely parse incoming strings to unicode
- def _str(s):
- return s.encode('utf-8').strip()
- #Google maps link
- def gmaps_link(lat, lng):
- latLon = '{},{}'.format(repr(lat), repr(lng))
- return 'http://maps.google.com/maps?q={}'.format(latLon)
- # Notify user for discovered Pokemon
- def pokemon_found(pokemon):
- global wanted_pokemon
- # get name
- pokename = pokemon_names[str(pokemon['id'])]
- # check array
- if not pushbullet_client:
- #print "[-] %%%%%%%%%%%% Notifier error: pushbullet failure"
- return
- if not pokename in wanted_pokemon:
- #print "[-] %%%%%%%%%%%% Notifier error: pokemon not wanted"
- return
- # notify
- #print "[+] ************************************* Notifier found pokemon:", pokename
- google_maps_link = gmaps_link(pokemon["lat"], pokemon["lng"])
- notification_text = "Pokemon Finder found " + _str(pokename) + "!"
- disappear_time = str(datetime.fromtimestamp(pokemon["disappear_time"]).strftime("%I:%M%p").lstrip('0'))+")"
- location_text = "Locate on Google Maps : " + google_maps_link + ". " + _str(pokename) + " will be available until " + disappear_time + "."
- push = pushbullet_client.push_link(notification_text, google_maps_link, body=location_text)
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement