def ans(message): chat_id = message.message.chat.id if "balance_key" in message.data: coin = message.data.split('_')[2] coins = api_query('returnBalances') for i in coins.items(): if i[0] == coin: bot.send_message(chat_id, '''====================\n\n <b>Ваш баланс {0} {1}</b>\n\n===================='''.format(coin, i[1]), parse_mode='HTML') if message.data == 'wallet_return': bot.send_message(chat_id, '''\n\n✅ Вы в главном меню\n\n''', parse_mode='HTML', reply_markup=keyboard())
def balance_key(chat_id): keyboard = types.InlineKeyboardMarkup() coins = api_query('returnBalances') wallet = [] for i in coins.items(): if i[1] != '0.00000000': wallet.append(i[0]) for i in wallet: keyboard.add(types.InlineKeyboardButton(text=i,callback_data="balance_key_{0}".format(i))) keyboard.add(types.InlineKeyboardButton(text='⬅ Вернуться в главное меню',callback_data="wallet_return")) return keyboard
def send_anytext(message): chat_id = message.chat.id if message.text == '📖 Баланс': text = '✅ Ваш баланс \n\n' balance = api_query('returnBalances') for i in balance.items(): if i[1] != '0.00000000': print(i) text = text + '<b>' + i[0] + '</b>' + '\t --- \t' + i[1] + '\n' bot.send_message(chat_id, text, parse_mode='HTML', reply_markup=keyboard())