tg-bot/tipbot/commands/balance.py

19 lines
656 B
Python
Raw Permalink Normal View History

2020-08-06 06:52:13 +01:00
import logging
from tipbot import wownero
from tipbot import db
from tipbot.helpers.decorators import wallet_rpc_required, log_event, registration_required, check_debug
from tipbot.helpers.utils import reply_user
2020-08-06 06:52:13 +01:00
@wallet_rpc_required
@registration_required
@log_event
@check_debug
2020-08-06 06:52:13 +01:00
def balance(update, context):
2021-05-10 05:40:42 +01:00
u = db.User.get(telegram_id=update.message.from_user.id)
2020-08-06 06:52:13 +01:00
balances = wownero.Wallet().balances(account=u.account_index)
2021-05-10 05:40:42 +01:00
unlocked = float(balances[1])
locked = float(balances[0] - balances[1])
msg = f'Available balance for {u.telegram_user}: {unlocked} WOW ({locked} WOW locked)'
reply_user(update.message, context, msg)