diff --git a/src/lib/telegram/chat/__tests__/verifyTelegramCode.test.ts b/src/lib/telegram/chat/__tests__/verifyTelegramCode.test.ts index 6d64103e..c79032ff 100644 --- a/src/lib/telegram/chat/__tests__/verifyTelegramCode.test.ts +++ b/src/lib/telegram/chat/__tests__/verifyTelegramCode.test.ts @@ -116,7 +116,7 @@ describe('verifyTelegramCode', () => { }); expect(clearPendingCode).toHaveBeenCalledWith(thread); expect(thread.post).toHaveBeenCalledWith( - expect.stringContaining('Welcome to In Process') + expect.stringContaining("You're all set") ); }); }); diff --git a/src/lib/telegram/chat/commands/handleStart.ts b/src/lib/telegram/chat/commands/handleStart.ts index a55ec7f6..90b90ac5 100644 --- a/src/lib/telegram/chat/commands/handleStart.ts +++ b/src/lib/telegram/chat/commands/handleStart.ts @@ -6,7 +6,7 @@ const handleStart = async ( artistUsername: string | null, telegramUsername: string ) => { - const text = `Hello ${artistUsername || telegramUsername}, welcome to In Process! Your telegram has been verified! You can now send photos and captions to post them on In Process.`; + const text = `Hello ${artistUsername || telegramUsername}, Your telegram has been connected! You can now send photos and captions to post them on In Process.`; await thread.post(text); }; diff --git a/src/lib/telegram/chat/connectTelegramToAccount.ts b/src/lib/telegram/chat/connectTelegramToAccount.ts index c06a9392..15b69fca 100644 --- a/src/lib/telegram/chat/connectTelegramToAccount.ts +++ b/src/lib/telegram/chat/connectTelegramToAccount.ts @@ -6,11 +6,10 @@ import selectWallets from '@/lib/supabase/in_process_wallets/selectWallets'; import sendCodeHandler from '@/lib/oauth/sendCodeHandler'; import clearPendingEmail from './clearPendingEmail'; import setPendingCode from './setPendingCode'; - -const INVALID_EMAIL_MESSAGE = - "That doesn't look like a valid email address. Please try again."; -const CODE_SENT_MESSAGE = - "We've sent a 6-digit verification code to that email. Please reply with the code to confirm it's yours."; +import { + TELEGRAM_INVALID_EMAIL_MESSAGE, + TELEGRAM_CODE_SENT_MESSAGE, +} from './consts'; async function connectTelegramToAccount( thread: Thread, @@ -18,7 +17,7 @@ async function connectTelegramToAccount( ): Promise { const result = telegramEmailSchema.safeParse(text); if (!result.success) { - await thread.post(INVALID_EMAIL_MESSAGE); + await thread.post(TELEGRAM_INVALID_EMAIL_MESSAGE); return; } @@ -43,7 +42,7 @@ async function connectTelegramToAccount( username: artist?.username ?? null, }); await clearPendingEmail(thread); - await thread.post(CODE_SENT_MESSAGE); + await thread.post(TELEGRAM_CODE_SENT_MESSAGE); } export default connectTelegramToAccount; diff --git a/src/lib/telegram/chat/consts.ts b/src/lib/telegram/chat/consts.ts index b0a1e07b..f1d2f891 100644 --- a/src/lib/telegram/chat/consts.ts +++ b/src/lib/telegram/chat/consts.ts @@ -24,3 +24,23 @@ export const TELEGRAM_PENDING_CODE_TTL_MS = 10 * 60 * 1_000; /** Debounce window for batching media (real Telegram albums and synthesized ungrouped bursts). */ export const MEDIA_GROUP_WINDOW_MS = 10_000; + +/** Shown when a Telegram user without a linked account sends any message. */ +export const TELEGRAM_NOT_CONNECTED_MESSAGE = + 'Welcome to In Process! To get started, please reply with the email you use for In Process so we can connect your Telegram.'; + +/** Shown when the reply to the email prompt isn't a valid email address. */ +export const TELEGRAM_INVALID_EMAIL_MESSAGE = + "That doesn't look like a valid email address. Please try again."; + +/** Shown after a verification code has been emailed, whether or not an artist was matched (avoids leaking which emails have an account). */ +export const TELEGRAM_CODE_SENT_MESSAGE = + "We've sent a 6-digit verification code to that email. Please reply with the code to confirm it's yours."; + +/** Shown when the reply to the code prompt is malformed or Privy rejects the code. */ +export const TELEGRAM_INVALID_CODE_MESSAGE = + "That code doesn't look right. Please check your email and try again."; + +/** Shown once a Telegram account is successfully connected, whether to an existing or newly created artist. */ +export const telegramConnectedMessage = (username: string | null) => + `You're all set! Your Telegram is now connected to your In Process account${username ? ` (${username})` : ''}. You can now send photos, videos, or YouTube links to create moments.`; diff --git a/src/lib/telegram/chat/handlers/__tests__/onNewMention.test.ts b/src/lib/telegram/chat/handlers/__tests__/onNewMention.test.ts index 10d04353..6afb1e38 100644 --- a/src/lib/telegram/chat/handlers/__tests__/onNewMention.test.ts +++ b/src/lib/telegram/chat/handlers/__tests__/onNewMention.test.ts @@ -125,7 +125,7 @@ describe('onNewMention', () => { it('delegates to commandsHandler and returns when handled', async () => { vi.mocked(commandsHandler).mockResolvedValue(true); - await capturedHandler!(makeThread(), makeMessage({ text: '/start' })); + await capturedHandler!(makeThread(), makeMessage({ text: '/remind' })); expect(processMediaThread).not.toHaveBeenCalled(); }); @@ -145,7 +145,7 @@ describe('onNewMention', () => { await capturedHandler!(thread, makeMessage({ text: 'random text' })); expect(thread.post).toHaveBeenCalledWith( - 'Please send a photo or video with a caption.' + 'To post moments, please send a photo or video along with a caption, or share a YouTube link.' ); }); diff --git a/src/lib/telegram/chat/handlers/onNewMention.ts b/src/lib/telegram/chat/handlers/onNewMention.ts index 78ab002d..9954b97f 100644 --- a/src/lib/telegram/chat/handlers/onNewMention.ts +++ b/src/lib/telegram/chat/handlers/onNewMention.ts @@ -57,7 +57,9 @@ export function registerOnNewMention(bot: TelegramChatBot) { return; } - await thread.post('Please send a photo or video with a caption.'); + await thread.post( + 'To post moments, please send a photo or video along with a caption, or share a YouTube link.' + ); } catch (error) { console.error('[telegram-dm] onDirectMessage error:', error); await thread.post(`❌ something went wrong: ${error}`); diff --git a/src/lib/telegram/chat/promptTelegramEmail.ts b/src/lib/telegram/chat/promptTelegramEmail.ts index 1d1799de..db1419d1 100644 --- a/src/lib/telegram/chat/promptTelegramEmail.ts +++ b/src/lib/telegram/chat/promptTelegramEmail.ts @@ -1,14 +1,12 @@ import type { Thread } from 'chat'; import type { TelegramThreadState } from './telegramThreadState'; import setPendingEmail from './setPendingEmail'; - -const NOT_CONNECTED_MESSAGE = - "We couldn't find an In Process account connected to this Telegram yet. To connect it, please reply with the email address you use for In Process."; +import { TELEGRAM_NOT_CONNECTED_MESSAGE } from './consts'; async function promptTelegramEmail( thread: Thread ): Promise { - await thread.post(NOT_CONNECTED_MESSAGE); + await thread.post(TELEGRAM_NOT_CONNECTED_MESSAGE); await setPendingEmail(thread); } diff --git a/src/lib/telegram/chat/verifyTelegramCode.ts b/src/lib/telegram/chat/verifyTelegramCode.ts index ce2dae9e..f970390f 100644 --- a/src/lib/telegram/chat/verifyTelegramCode.ts +++ b/src/lib/telegram/chat/verifyTelegramCode.ts @@ -8,11 +8,10 @@ import getOrCreateArtist from '@/lib/artists/getOrCreateArtist'; import { upsertArtists } from '@/lib/supabase/in_process_artists/upsertArtists'; import clearPendingCode from './clearPendingCode'; import type { PendingCode } from './getPendingCode'; - -const INVALID_CODE_MESSAGE = - "That code doesn't look right. Please check your email and try again."; -const WELCOME_MESSAGE = - "Welcome to In Process! We've created your account and connected your Telegram. You can now send photos and videos to publish moments."; +import { + TELEGRAM_INVALID_CODE_MESSAGE, + telegramConnectedMessage, +} from './consts'; async function verifyTelegramCode( thread: Thread, @@ -22,7 +21,7 @@ async function verifyTelegramCode( ): Promise { const result = telegramCodeSchema.safeParse(text); if (!result.success) { - await thread.post(INVALID_CODE_MESSAGE); + await thread.post(TELEGRAM_INVALID_CODE_MESSAGE); return; } @@ -33,12 +32,13 @@ async function verifyTelegramCode( result.data ); } catch { - await thread.post(INVALID_CODE_MESSAGE); + await thread.post(TELEGRAM_INVALID_CODE_MESSAGE); return; } await clearPendingCode(thread); + const connectedMessage = telegramConnectedMessage(pending.username); if (!pending.artistId) { const walletAddress = await ensurePrivySocialWallet(authResult); const artist = await getOrCreateArtist({ @@ -46,14 +46,12 @@ async function verifyTelegramCode( type: 'privy', }); await upsertArtists({ id: artist.artistId, telegram: telegramUsername }); - await thread.post(WELCOME_MESSAGE); + await thread.post(connectedMessage); return; } await upsertArtists({ id: pending.artistId, telegram: telegramUsername }); - await thread.post( - `You're all set! Your Telegram is now connected to your In Process account${pending.username ? ` (${pending.username})` : ''}. You can now send photos and videos to publish moments.` - ); + await thread.post(connectedMessage); } export default verifyTelegramCode;