Make telegram message beautiful

This commit is contained in:
Anton 2018-05-15 13:37:34 +03:00
parent f175f48418
commit d112d90e8e
2 changed files with 14 additions and 16 deletions

View File

@ -264,17 +264,15 @@ class Telegram(RPC):
(currencys, total, symbol, value) = result (currencys, total, symbol, value) = result
output = '' output = ''
for currency in currencys: for currency in currencys:
output += """*Currency*: {currency} output += "*{currency}:*\n" \
*Available*: {available} "\t`Available: {available: .8f}`\n" \
*Balance*: {balance} "\t`Balance: {balance: .8f}`\n" \
*Pending*: {pending} "\t`Pending: {pending: .8f}`\n" \
*Est. BTC*: {est_btc: .8f} "\t`Est. BTC: {est_btc: .8f}`\n".format(**currency)
""".format(**currency)
output += """*Estimated Value*: output += "\n*Estimated Value*:\n" \
*BTC*: {0: .8f} "\t`BTC: {0: .8f}`\n" \
*{1}*: {2: .2f} "\t`{1}: {2: .2f}`\n".format(total, symbol, value)
""".format(total, symbol, value)
self.send_msg(output) self.send_msg(output)
@authorized_only @authorized_only

View File

@ -614,12 +614,12 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None:
telegram._balance(bot=MagicMock(), update=update) telegram._balance(bot=MagicMock(), update=update)
result = msg_mock.call_args_list[0][0][0] result = msg_mock.call_args_list[0][0][0]
assert msg_mock.call_count == 1 assert msg_mock.call_count == 1
assert '*Currency*: BTC' in result assert '*BTC:*' in result
assert '*Currency*: ETH' not in result assert '*ETH:*' not in result
assert '*Currency*: USDT' in result assert '*USDT:*' in result
assert 'Balance' in result assert 'Balance:' in result
assert 'Est. BTC' in result assert 'Est. BTC:' in result
assert '*BTC*: 14.00000000' in result assert 'BTC: 14.00000000' in result
def test_zero_balance_handle(default_conf, update, mocker) -> None: def test_zero_balance_handle(default_conf, update, mocker) -> None: