forked from kodorvan/stcs
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import logging.config
|
|
|
|
from aiogram.fsm.context import FSMContext
|
|
from aiogram.types import Message
|
|
|
|
import app.telegram.keyboards.inline as kbi
|
|
import database.request as rq
|
|
from app.bybit.get_functions.get_balance import get_balance
|
|
from app.bybit.get_functions.get_tickers import get_tickers
|
|
from app.bybit.logger_bybit.logger_bybit import LOGGING_CONFIG
|
|
|
|
logging.config.dictConfig(LOGGING_CONFIG)
|
|
logger = logging.getLogger("profile_bybit")
|
|
|
|
|
|
async def user_profile_bybit(tg_id: int, message: Message, state: FSMContext) -> None:
|
|
"""Get user profile bybit"""
|
|
try:
|
|
await state.clear()
|
|
wallet = await get_balance(tg_id=tg_id)
|
|
|
|
if wallet:
|
|
balance = wallet.get("totalWalletBalance", "0")
|
|
symbol = await rq.get_user_symbol(tg_id=tg_id)
|
|
get_tickers_info = await get_tickers(tg_id=tg_id, symbol=symbol)
|
|
price_symbol = get_tickers_info.get("lastPrice") or 0
|
|
await message.answer(
|
|
text=f"💎Ваш профиль Bybit:\n\n"
|
|
f"⚖️ Баланс: {float(balance):,.2f} USD\n"
|
|
f"📊Торговая пара: {symbol}\n"
|
|
f"$$$ Цена: {float(price_symbol):,.4f}\n",
|
|
reply_markup=kbi.main_menu,
|
|
)
|
|
else:
|
|
await message.answer(
|
|
text="Ошибка при подключении, повторите попытку",
|
|
reply_markup=kbi.connect_the_platform,
|
|
)
|
|
logger.error("Error processing user profile for user %s", tg_id)
|
|
except Exception as e:
|
|
logger.error("Error processing user profile for user %s: %s", tg_id, e)
|