dev@locazia: add callback initTonconnect
This commit is contained in:
parent
35e58d3360
commit
9ea251ec01
|
|
@ -41,12 +41,8 @@ async def t_home_menu(__msg, **extra):
|
||||||
'text': f"{wallets[i + 1]['name']}",
|
'text': f"{wallets[i + 1]['name']}",
|
||||||
'callback_data': f"initTonconnect_{wallets[i + 1]['app_name']}"
|
'callback_data': f"initTonconnect_{wallets[i + 1]['app_name']}"
|
||||||
} if i + 1 < len(wallets) else None,
|
} 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)
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from aiogram import types, Router
|
from aiogram import types, Router, F
|
||||||
from aiogram.filters import Command
|
from aiogram.filters import Command
|
||||||
|
|
||||||
from app.core._keyboards import get_inline_keyboard
|
from app.core._keyboards import get_inline_keyboard
|
||||||
|
|
@ -64,4 +64,27 @@ Use /dev_tonconnect <code>{wallet_app_name}</code> for connect to wallet."""
|
||||||
keyboard=get_inline_keyboard(keyboard) if keyboard else None
|
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.message.register(t_tonconnect_dev_menu, Command('dev_tonconnect'))
|
||||||
|
router.callback_query.register(t_callback_init_tonconnect, F.data.startswith('initTonconnect_'))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue