From bea31fe8f201ed6797ba1e96ba73bbccbe3662e3 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Wed, 13 May 2026 21:07:32 +0700 Subject: [PATCH] Move bot login timer into message text --- src/auth/telegram-bot-login.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/auth/telegram-bot-login.ts b/src/auth/telegram-bot-login.ts index 88c38d9..fa13621 100644 --- a/src/auth/telegram-bot-login.ts +++ b/src/auth/telegram-bot-login.ts @@ -129,7 +129,7 @@ function loginReplyMarkup(token: string, expiresAt: Date) { inline_keyboard: [ [ { - text: `Открыть MapFlow · ${formatRemaining(expiresAt)}`, + text: 'Открыть MapFlow', url: `${config.webAppUrl}?telegram_login=${encodeURIComponent(token)}`, }, ], @@ -137,6 +137,15 @@ function loginReplyMarkup(token: string, expiresAt: Date) { }; } +function loginMessageText(expiresAt: Date) { + return [ + 'Вход в MapFlow', + '', + 'Перейдите по ссылке ниже.', + `Ссылка активна: ${formatRemaining(expiresAt)}`, + ].join('\n'); +} + async function sendLoginMessage( chatId: number, text: string, @@ -206,7 +215,7 @@ function scheduleLoginMessageTimer( return; } - await editLoginMessage(chatId, messageId, 'MapFlow', token, expiresAt); + await editLoginMessage(chatId, messageId, loginMessageText(expiresAt), token, expiresAt); const handle = setTimeout(() => { void tick(); }, 1000); @@ -267,7 +276,7 @@ export async function completeTelegramBotLogin(token: string) { await editLoginMessage( request.telegramChatId, request.telegramMessageId, - 'Вход выполнен.', + 'Вход выполнен.\nМожно вернуться в MapFlow.', ); } @@ -295,7 +304,7 @@ export async function handleTelegramBotWebhook( const [command, payload] = text.split(' '); if (command !== '/start' || !payload?.startsWith(loginPrefix)) { - await sendLoginMessage(chatId, 'Открой вход с сайта MapFlow.'); + await sendLoginMessage(chatId, 'Начните вход с сайта MapFlow.'); return; } @@ -305,7 +314,7 @@ export async function handleTelegramBotWebhook( }); if (!request || request.status !== 'PENDING' || request.expiresAt <= new Date()) { - await sendLoginMessage(chatId, 'Ссылка входа устарела.'); + await sendLoginMessage(chatId, 'Ссылка входа устарела.\nВернитесь на сайт и начните вход заново.'); return; } @@ -322,7 +331,12 @@ export async function handleTelegramBotWebhook( }, }); - const sentMessage = await sendLoginMessage(chatId, 'MapFlow', token, request.expiresAt); + const sentMessage = await sendLoginMessage( + chatId, + loginMessageText(request.expiresAt), + token, + request.expiresAt, + ); await prisma.telegramLoginRequest.update({ where: { id: request.id },