Skip to content

Commit

Permalink
add shiny icon, parkname as g-link
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzamann113 committed Oct 31, 2019
1 parent 3f0721f commit a9afde9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ The script will use each config in the `custom_configs` folder, one after the ot
| `USERNAME` | Username the Bot uses for sending data | `String` | `Nest-Bot` |
| `LANGUAGE` | Language for the Pokemon named (`en`, `de`, `fr`, `jp`, `cz` ) | `String` | `en` |
| `SORT_BY` | For which value the list should be sorted by:<br /> `name` -> Park Name<br /> `pokemon_id` -> Pokedex Nr<br /> `pokemon_name` -> Pokemon Name (Language specific)<br /> `pokemon_avg` -> Average Sighting | `String` | `name` |
| `SORT_REVERSE` | For reversing the order: `True` | `False` | `Boolean` | `False` |
| `IGNORE_UNNAMED` | Ignore Parks without Names | `Boolean` | `True` |
| `TITLE` | Title which will be written before the nest list <br /> Available Blocks: `{park_name}` | `String` | `**This is the Nest report for {area_name}**` |
| `TEXT` | Text which will be used to send to Discord <br /> Available Blocks: `{park_name}`, `{poke_name}`, `{poke_type}`,`{poke_type_emoji}`,`{poke_avg}`, `{g_maps}`, `{time}` | `String` | `**{park_name}**: {poke_name} ({poke_type_emoji}) => {poke_avg} per hour {g_maps} *[checked at {time}]*` |
| `TEXT` | Text which will be used to send to Discord <br /> Available Blocks: `{park_name}`, `{poke_name_g}`, `{poke_shiny}`,`{poke_type}`,`{poke_type_emoji}`,`{poke_avg}`, `{g_maps}`, `{time}` | `String` | `**{park_name_g}**: {poke_name} {poke_shiny} ({poke_type_emoji}) => {poke_avg} per hour` |
| `LOCALE_FILE` | Locale file which should be used (for example custom emojis) | `String` | `locale.json` |


Expand Down
30 changes: 22 additions & 8 deletions analyze_nests.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def create_config(config_path):
config['dc-sort-by'] = config_raw.get(
'Discord',
'SORT_BY')
config['dc-sort-reverse'] = config_raw.getboolean(
'Discord',
'SORT_REVERSE')
config['dc-ignore-unnamed'] = config_raw.getboolean(
'Discord',
'IGNORE_UNNAMED')
Expand Down Expand Up @@ -735,12 +738,12 @@ def _convert_way(way):
max_lon=max_lon
)
mycursor_r.execute(spawnpoint_sel_query)
my_result_spawnsoints = mycursor_r.fetchall()
my_result_spawnpoints = mycursor_r.fetchall()
_city_progress(idx, areas_len, "({}/{}) {}".format(
idx,
areas_len,
"Got all wanted Spawnpoints - now filter them"))
for spwn in my_result_spawnsoints:
for spwn in my_result_spawnpoints:
spwn_point = geometry.Point(spwn[2], spwn[1])
if spwn_point.within(geometry.shape(area_points)):
area_spawnpoints[spwn[0]] = spwn_point
Expand Down Expand Up @@ -840,6 +843,7 @@ def _convert_way(way):
all_areas.append(area)
insert_args["pokemon_name"] = poke_names[str(area_poke[0])][config["dc-language"]]
insert_args["pokemon_type"] = poke_names[str(area_poke[0])]["type"]
insert_args["pokemon_shiny"] = poke_names[str(area_poke[0])]["shiny"]
areas_basic[str(area['id'])] = insert_args

mydb_r.close()
Expand All @@ -857,13 +861,13 @@ def _convert_way(way):

def discord_webhook():
# Sort basic areas
sorted_basic_areas = sorted(
areas_basic.items(),
key=lambda kv: kv[1][config["dc-sort-by"]])
sorted_b_areas_dict = OrderedDict(sorted_basic_areas)
sorted_basic_areas = OrderedDict(sorted(
areas_basic.items(),
key=lambda kv: kv[1][config["dc-sort-by"]],
reverse=config["dc-sort-reverse"]))
content = defaultdict(str)
content_page = 0
for b_area in sorted_b_areas_dict.values():
for b_area in sorted_basic_areas.values():
if config['dc-ignore-unnamed'] and (b_area["name"] == config["default_park_name"]):
continue
nest_time = datetime.utcfromtimestamp(
Expand All @@ -872,15 +876,25 @@ def discord_webhook():
lat=b_area["lat"],
lon=b_area["lon"]
)
park_name = b_area["name"]
g_maps = "[Google Maps]({})".format(map_ref)
park_name_g = u"[{name}]({map_ref})".format(
name=park_name,
map_ref=map_ref)

poke_shiny = ""
if b_area["pokemon_shiny"]:
poke_shiny = locale["poke-shiny-emoji"] + " "
# convert types:
poke_type_emojis = list()
for typ in b_area["pokemon_type"]:
poke_type_emojis.append(locale["poke-type-emoji"][typ])
text = (config["dc-text"] + u"\n").format(
park_name=b_area["name"],
park_name=park_name,
park_name_g=park_name_g,
poke_id=b_area["pokemon_id"],
poke_name=b_area["pokemon_name"],
poke_shiny=poke_shiny,
poke_avg=b_area["pokemon_avg"],
poke_type="/".join(b_area["pokemon_type"]),
poke_type_emoji="/".join(poke_type_emojis),
Expand Down
3 changes: 2 additions & 1 deletion default.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ WEBHOOK = ["https://discordapp.com/api/webhooks/xxxxx/xxxxxx"]
USERNAME = Nest-Bot
LANGUAGE = en
SORT_BY = pokemon_name
SORT_REVERSE = False
IGNORE_UNNAMED = True
TITLE = **This is the Nest report for {area_name}**
TEXT = **{park_name}**: {poke_name} ({poke_type_emoji}) => {poke_avg} per hour {g_maps} *[checked at {time}]*
TEXT = **{park_name_g}**: {poke_name} {poke_shiny}({poke_type_emoji}) => {poke_avg} per hour
LOCALE_FILE = locale.json

[Other]
Expand Down
3 changes: 2 additions & 1 deletion locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"Ice":"",
"Ghost":"👻",
"Dragon":"🐲"
}
},
"poke-shiny-emoji":""
}
2 changes: 1 addition & 1 deletion poke_names.json

Large diffs are not rendered by default.

0 comments on commit a9afde9

Please sign in to comment.