dev@locazia: add connected message

This commit is contained in:
user 2024-02-29 00:33:07 +03:00
parent 3618a54282
commit b769dabf17
1 changed files with 15 additions and 2 deletions

View File

@ -8,7 +8,8 @@ from app.core._utils.tg_process_template import tg_process_template
from app.core.logger import make_log
from app.core.models._blockchain.ton.connect import TonConnect, unpack_wallet_info
from app.core.models.wallet_connection import WalletConnection
from app.bot.routers.home import send_connect_wallets_list
from app.bot.routers.home import send_connect_wallets_list, send_home_menu
from datetime import datetime, timedelta
router = Router()
@ -76,7 +77,7 @@ async def t_callback_init_tonconnect(query: types.CallbackQuery, memory=None, us
memory.add_task(pause_ton_connection, ton_connect, delay_s=60 * 3)
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(
r = await tg_process_template(
chat_wrap, message_text,
keyboard=get_inline_keyboard([
[
@ -88,6 +89,18 @@ async def t_callback_init_tonconnect(query: types.CallbackQuery, memory=None, us
]), message_id=query.message.message_id
)
start_ts = datetime.now()
while datetime.now() - start_ts < timedelta(seconds=180):
new_connection = db_session.query(WalletConnection).filter(
WalletConnection.user_id == user.id,
WalletConnection.invalidated == False
).first()
if new_connection:
await send_home_menu(chat_wrap, user, new_connection)
break
return r
async def t_callback_disconnect_wallet(query: types.CallbackQuery, memory=None, user=None, db_session=None, chat_wrap=None, **extra):
wallet_connections = db_session.query(WalletConnection).filter(