diff --git a/app/bot/routers/home.py b/app/bot/routers/home.py index 5b95ab1..eedaadd 100644 --- a/app/bot/routers/home.py +++ b/app/bot/routers/home.py @@ -11,7 +11,7 @@ from aiogram.filters import Command main_router = Router() -async def send_home_menu(chat_wrap, user, wallet_connection): +async def send_home_menu(chat_wrap, user, wallet_connection, **kwargs): return await tg_process_template( chat_wrap, user.translated('home_menu').format( wallet_address=wallet_connection.wallet_address @@ -24,11 +24,11 @@ async def send_home_menu(chat_wrap, user, wallet_connection): 'text': user.translated('disconnectWallet_button'), 'callback_data': 'disconnectWallet' }] - ]) + ]), **kwargs ) -async def send_connect_wallets_list(db_session, chat_wrap, user): +async def send_connect_wallets_list(db_session, chat_wrap, user, **kwargs): ton_connect, ton_connection = TonConnect.by_user(db_session, user, callback_fn=()) await ton_connect.restore_connection() wallets = ton_connect._sdk_client.get_wallets() @@ -47,7 +47,7 @@ async def send_connect_wallets_list(db_session, chat_wrap, user): } if i + 1 < len(wallets) else None, ] for i in range(0, len(wallets), 2) - ]) + ]), **kwargs ) @@ -56,15 +56,22 @@ async def t_home_menu(__msg, **extra): if extra.get('state'): await extra['state'].clear() + if isinstance(__msg, types.CallbackQuery): + message_id = __msg.message.message_id + elif isinstance(__msg, types.Message): + message_id = __msg.message_id + else: + message_id = None + wallet_connection = db_session.query(WalletConnection).filter( WalletConnection.user_id == user.id, WalletConnection.invalidated == False ).first() if not wallet_connection: - return await send_connect_wallets_list(db_session, chat_wrap, user) + return await send_connect_wallets_list(db_session, chat_wrap, user, message_id=message_id) - return await send_home_menu(chat_wrap, user, wallet_connection) + return await send_home_menu(chat_wrap, user, wallet_connection, message_id=message_id) main_router.message.register(t_home_menu, Command('start')) diff --git a/app/bot/routers/tonconnect.py b/app/bot/routers/tonconnect.py index 34afbcd..79d7449 100644 --- a/app/bot/routers/tonconnect.py +++ b/app/bot/routers/tonconnect.py @@ -98,7 +98,7 @@ async def t_callback_disconnect_wallet(query: types.CallbackQuery, memory=None, wallet_connection.invalidated = True db_session.commit() - return await send_connect_wallets_list(db_session, chat_wrap, user) + return await send_connect_wallets_list(db_session, chat_wrap, user, message_id=query.message.message_id) router.message.register(t_tonconnect_dev_menu, Command('dev_tonconnect')) router.callback_query.register(t_callback_init_tonconnect, F.data.startswith('initTonconnect_'))