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

Commit

Permalink
Properly encode pokemon name messages
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhe committed Jul 21, 2016
1 parent c7ee273 commit 690a1bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,11 @@ def process_step(args, api_endpoint, access_token, profile_response,
pokename = pokemonsJSON[pokeid]
if args.ignore:
if pokename.lower() in ignore or pokeid in ignore:
debug("{} was on the `ignore` list.".format(pokename))
debug("{} was on the `ignore` list.".format(pokename.encode('utf-8')))
continue
elif args.only:
if pokename.lower() not in only and pokeid not in only:
debug("{} was not on the `only` list.".format(pokename))
debug("{} was not on the `only` list.".format(pokename.encode('utf-8')))
continue

disappear_timestamp = time.time() + poke.TimeTillHiddenMs \
Expand All @@ -672,10 +672,10 @@ def process_step(args, api_endpoint, access_token, profile_response,
poke_coords = (poke.Latitude, poke.Longitude)
distance = distance_in_meters(origin_coords, poke_coords)
if distance > int(args.distance_limit):
debug("Pokemon {} skipped due to being {}m away.".format(pokename, distance))
debug("Pokemon {} skipped due to being {}m away.".format(pokename.encode('utf-8'), distance))
continue
else:
debug("Pokemon {} found {}m away.".format(pokename, distance))
debug("Pokemon {} found {}m away.".format(pokename.encode('utf-8'), distance))

pokemon_obj = {
"lat": poke.Latitude,
Expand All @@ -686,7 +686,7 @@ def process_step(args, api_endpoint, access_token, profile_response,
}

if poke.SpawnPointId not in pokemons:
debug("Notifying about {}".format(pokename))
debug("Notifying about {}".format(pokename.encode('utf-8')))
notifier.pokemon_found(pokemon_obj)

pokemons[poke.SpawnPointId] = pokemon_obj
Expand Down
2 changes: 1 addition & 1 deletion notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _str(s):
# Notify user for discovered Pokemon
def pokemon_found(pokemon):
# get name
pokename = _str( pokemon["name"] ).lower()
pokename = _str(pokemon["name"]).lower()

# get address
coords = "{}, {}".format(str(pokemon["lat"]), str(pokemon["lng"]))
Expand Down
5 changes: 4 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import notifier
pokemon = { "lat": 38.8977, "lng": -77.0365, "name": "Pidgey", "disappear_time": 1469053206 }
pokemon = { "lat": 38.8977, "lng": -77.0365, "name": u'Nidoran♀', "disappear_time": 1469053206 }
notifier.pokemon_found( pokemon )

0 comments on commit 690a1bb

Please sign in to comment.