diff --git a/app/bot/routers/index.py b/app/bot/routers/index.py index 6b57647..e11ba3b 100644 --- a/app/bot/routers/index.py +++ b/app/bot/routers/index.py @@ -41,12 +41,8 @@ async def t_home_menu(__msg, **extra): 'text': f"{wallets[i + 1]['name']}", 'callback_data': f"initTonconnect_{wallets[i + 1]['app_name']}" } if i + 1 < len(wallets) else None, - { - 'text': f"{wallets[i + 2]['name']}", - 'callback_data': f"initTonconnect_{wallets[i + 2]['app_name']}" - } if i + 2 < len(wallets) else None, ] - for i in range(0, len(wallets), 3) + for i in range(0, len(wallets), 2) ]) ) diff --git a/app/bot/routers/tonconnect.py b/app/bot/routers/tonconnect.py index cdf3821..925ecea 100644 --- a/app/bot/routers/tonconnect.py +++ b/app/bot/routers/tonconnect.py @@ -1,6 +1,6 @@ import json -from aiogram import types, Router +from aiogram import types, Router, F from aiogram.filters import Command from app.core._keyboards import get_inline_keyboard @@ -64,4 +64,27 @@ Use /dev_tonconnect {wallet_app_name} for connect to wallet.""" keyboard=get_inline_keyboard(keyboard) if keyboard else None ) + +async def t_callback_init_tonconnect(query: types.CallbackQuery, memory=None, user=None, db_session=None, chat_wrap=None, **extra): + wallet_app_name = query.data.split("_")[1] + ton_connect, ton_connection = TonConnect.by_user(db_session, user, callback_fn=()) + await ton_connect.restore_connection() + connection_link = await ton_connect.new_connection(wallet_app_name) + ton_connect.connected + make_log("TonConnect_Init", f"New connection link for {wallet_app_name}: {connection_link}", level='debug') + message_text = user.translated("tonconnectInit_menu") + return await tg_process_template( + chat_wrap, message_text, + keyboard=get_inline_keyboard([ + [ + { + 'text': 'Connect', + 'url': connection_link + } + ] + ]) + ) + + router.message.register(t_tonconnect_dev_menu, Command('dev_tonconnect')) +router.callback_query.register(t_callback_init_tonconnect, F.data.startswith('initTonconnect_'))