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 formatting and msg consolidation #5583

Merged
merged 2 commits into from
Sep 21, 2016
Merged
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
71 changes: 22 additions & 49 deletions pokemongo_bot/event_handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def showtop(self, chatid, num, order):

pkmns = sorted(inventory.pokemons().all(), key=lambda p: getattr(p, order), reverse=True)[:num]

outMsg = "\n".join(["*{}* \nCP:{} \nIV:{} \nCandy:{}\n".format(p.name, p.cp, p.iv,
outMsg = "\n".join(["*{}* (_CP:_ {}) (_IV:_ {}) (Candy:{})".format(p.name, p.cp, p.iv,
inventory.candies().get(p.pokemon_id).quantity) for p
in pkmns])
self.sendMessage(chat_id=chatid, parse_mode='Markdown', text=outMsg)
Expand All @@ -153,16 +153,11 @@ def get_evolved(self, chat_id, num, order):
cur = conn.cursor()
cur.execute("SELECT * FROM evolve_log ORDER BY " + order + " DESC LIMIT " + str(num))
evolved = cur.fetchall()
outMsg = ''
if evolved:
for x in evolved:
res = (
"*"+str(x[0])+"*",
"_CP:_ " + str(x[2]),
"_IV:_ " + str(x[1]),
str(x[3])
)

self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(_CP:_ ' + str(int(x[2])) + ') (_IV:_ ' + str(x[1]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Evolutions Found.\n")

Expand All @@ -171,12 +166,11 @@ def get_softban(self, chat_id):
cur = conn.cursor()
cur.execute("SELECT * FROM softban_log")
softban = cur.fetchall()
outMsg = ''
if softban:
for x in softban:
res = (
"*" + str(x[0]) + "*",
str(x[2]))
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(' + str(x[2]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Softbans found! Good job!\n")

Expand All @@ -192,15 +186,11 @@ def get_hatched(self, chat_id, num, order):
cur = conn.cursor()
cur.execute("SELECT * FROM eggs_hatched_log ORDER BY " + order + " DESC LIMIT " + str(num))
hatched = cur.fetchall()
outMsg = ''
if hatched:
for x in hatched:
res = (
"*" + str(x[0]) + "*",
"_CP:_ " + str(x[1]),
"_IV:_ " + str(x[2]),
str(x[4])
)
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(_CP:_ ' + str(int(x[1])) + ') (_IV:_ ' + str(x[2]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Eggs Hatched Yet.\n")

Expand All @@ -217,15 +207,11 @@ def get_caught(self, chat_id, num, order):
cur = conn.cursor()
cur.execute("SELECT * FROM catch_log ORDER BY " + order + " DESC LIMIT " + str(num))
caught = cur.fetchall()
outMsg = ''
if caught:
for x in caught:
res = (
"*" + str(x[0]) + "*",
"_CP:_ " + str(x[1]),
"_IV:_ " + str(x[2]),
str(x[5])
)
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(_CP:_ ' + str(int(x[2])) + ') (_IV:_ ' + str(x[1]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Pokemon Caught Yet.\n")

Expand All @@ -234,15 +220,11 @@ def get_pokestops(self, chat_id, num):
cur = conn.cursor()
cur.execute("SELECT * FROM pokestop_log ORDER BY dated DESC LIMIT " + str(num))
pokestop = cur.fetchall()
outMsg = ''
if pokestop:
for x in pokestop:
res = (
"*" + str(x[0] + "*"),
"_XP:_ " + str(x[1]),
"_Items:_ " + str(x[2]),
str(x[3])
)
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(_XP:_ ' + str(x[1]) + ') (_Items:_ ' + str(x[2]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Pokestops Encountered Yet.\n")

Expand All @@ -258,15 +240,11 @@ def get_released(self, chat_id, num, order):
cur = conn.cursor()
cur.execute("SELECT * FROM transfer_log ORDER BY " + order + " DESC LIMIT " + str(num))
transfer = cur.fetchall()
outMsg = ''
if transfer:
for x in transfer:
res = (
"*" + str(x[0]) + "*",
"_CP:_ " + str(x[2]),
"_IV:_ " + str(x[1]),
str(x[3])
)
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(_CP:_ ' + str(int(x[2])) + ') (_IV:_ ' + str(x[1]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Pokemon Released Yet.\n")

Expand All @@ -282,16 +260,11 @@ def get_vanished(self, chat_id, num, order):
cur = conn.cursor()
cur.execute("SELECT * FROM vanish_log ORDER BY " + order + " DESC LIMIT " + str(num))
vanished = cur.fetchall()
outMsg = ''
if vanished:
for x in vanished:
res = (
"*" + str(x[0]) + "*",
"_CP:_ " + str(x[1]),
"_IV:_ " + str(x[2]),
"_NCP:_ " + str(x[4]),
str(x[5])
)
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="\n".join(res))
outMsg += '*' + x[0] + '* ' + '(_CP:_ ' + str(int(x[1])) + ') (_IV:_ ' + str(x[2]) + ')\n'
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="".join(str(outMsg)))
else:
self.sendMessage(chat_id=chat_id, parse_mode='Markdown', text="No Pokemon Vanished Yet.\n")

Expand Down