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

Telegram task : Ordering by date #5688

Merged
merged 4 commits into from
Sep 27, 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
15 changes: 13 additions & 2 deletions docs/telegramtask.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,19 @@ This will subscribe you to be notified every time a Dratini has been caught with

> /top 10 iv

List top 10 pokemon, ordered by IV
List top 10 pokemon, ordered by IV, descending order

> /top 15 cp

List top 15 pokemon, ordered by CP
List top 15 pokemon, ordered by CP, descending order

> /top 5 dated

List top 5 pokemon, ordered by catching date, descending order

Same logic for :
/evolved <num> <cp-or-iv-or-dated>
/hatched <num> <cp-or-iv-or-dated>
/caught <num> <cp-or-iv-or-dated>
/released <num> <cp-or-iv-or-dated>
/vanished <num> <cp-or-iv-or-dated>
12 changes: 6 additions & 6 deletions pokemongo_bot/event_handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_evolved(self, num, order):
else:
num = int(num)

if order not in ["cp", "iv"]:
if order not in ["cp", "iv", "dated"]:
order = "iv"

with self.bot.database as conn:
Expand All @@ -45,7 +45,7 @@ def get_hatched(self, num, order):
else:
num = int(num)

if order not in ["cp", "iv"]:
if order not in ["cp", "iv", "dated"]:
order = "iv"

with self.bot.database as conn:
Expand All @@ -60,7 +60,7 @@ def get_caught(self, num, order):
else:
num = int(num)

if order not in ["cp", "iv"]:
if order not in ["cp", "iv", "dated"]:
order = "iv"

with self.bot.database as conn:
Expand All @@ -87,7 +87,7 @@ def get_released(self, num, order):
else:
num = int(num)

if order not in ["cp", "iv"]:
if order not in ["cp", "iv", "dated"]:
order = "iv"

with self.bot.database as conn:
Expand All @@ -102,7 +102,7 @@ def get_vanished(self, num, order):
else:
num = int(num)

if order not in ["cp", "iv"]:
if order not in ["cp", "iv", "dated"]:
order = "iv"

with self.bot.database as conn:
Expand Down Expand Up @@ -185,7 +185,7 @@ def get_top(self, num, order):
else:
num = int(num)

if order not in ["cp", "iv"]:
if order not in ["cp", "iv", "dated"]:
order = "iv"
pkmns = sorted(inventory.pokemons().all(), key=lambda p: getattr(p, order), reverse=True)[:num]
res = []
Expand Down