check if balance list is empty (fixes #105)

This commit is contained in:
gcarq 2017-11-16 00:01:47 +01:00
parent b5f58724a0
commit 4e05691cab

View File

@ -273,18 +273,21 @@ def _balance(bot: Bot, update: Update) -> None:
Handler for /balance Handler for /balance
Returns current account balance per crypto Returns current account balance per crypto
""" """
output = "" output = ''
balances = exchange.get_balances() balances = [
c for c in exchange.get_balances()
if c['Balance'] or c['Available'] or c['Pending']
]
if not balances:
output = '`All balances are zero.`'
for currency in balances: for currency in balances:
if not currency['Balance'] and not currency['Available'] and not currency['Pending']:
continue
output += """*Currency*: {Currency} output += """*Currency*: {Currency}
*Available*: {Available} *Available*: {Available}
*Balance*: {Balance} *Balance*: {Balance}
*Pending*: {Pending} *Pending*: {Pending}
""".format(**currency) """.format(**currency)
send_msg(output) send_msg(output)