Skip to content

Commit 66842f5

Browse files
authored
Merge pull request #36 from SpawnDock/feat/bot-bootstrap-created-message
fix(bot): update project creation message in Telegram bot
2 parents 1731ca2 + 90a65f0 commit 66842f5

3 files changed

Lines changed: 65 additions & 29 deletions

File tree

src/__tests__/bot-commands.test.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,42 @@ describe("parseCommand", () => {
4949
});
5050

5151
describe("bot messages", () => {
52-
it("createdMessage (ru) has spawn link and command", () => {
52+
it("createdMessage (ru) includes bootstrap steps and links", () => {
5353
const message = createdMessage(
5454
"ru",
5555
"demo-app",
56-
"npx -y @spawn-dock/cli spawn --token pair_demo",
57-
"spawndock://spawn?token=pair_demo",
56+
"npx @spawn-dock/create --token pair_demo",
57+
"https://spawn-dock.example/preview/demo-app",
58+
"https://t.me/TMASpawnerBot/tma?startapp=demo-app",
59+
"https://spawn-dock.example/tma?tgWebAppStartParam=demo-app",
5860
);
5961

60-
expect(message).not.toContain("Preview URL:");
61-
expect(message).not.toContain("Telegram Link:");
62-
expect(message).toContain("Нажми на ссылку, чтобы открыть рабочее окружение:");
63-
expect(message).toContain("spawndock://spawn?token=pair_demo");
64-
expect(message).toContain("Или запусти команду локально в терминале:");
65-
expect(message).toContain("npx -y @spawn-dock/cli spawn --token pair_demo");
62+
expect(message).toContain("Проект demo-app создан.");
63+
expect(message).toContain("1. Запусти bootstrap-команду локально:");
64+
expect(message).toContain("npx @spawn-dock/create --token pair_demo");
65+
expect(message).toContain("Эту команду можно запускать повторно для этого проекта.");
66+
expect(message).toContain("2. После bootstrap запусти:");
67+
expect(message).toContain("pnpm run dev");
68+
expect(message).toContain("Preview URL:");
69+
expect(message).toContain("Telegram Link:");
70+
expect(message).toContain("TMA URL:");
6671
});
6772

68-
it("createdMessage (en) uses English copy", () => {
73+
it("createdMessage (en) uses English bootstrap copy", () => {
6974
const message = createdMessage(
7075
"en",
7176
"demo-app",
72-
"npx -y @spawn-dock/cli spawn --token pair_demo",
73-
"spawndock://spawn?token=pair_demo",
77+
"npx @spawn-dock/create --token pair_demo",
78+
"https://spawn-dock.example/preview/demo-app",
79+
"https://t.me/TMASpawnerBot/tma?startapp=demo-app",
80+
"https://spawn-dock.example/tma?tgWebAppStartParam=demo-app",
7481
);
7582

76-
expect(message).toContain("Project");
77-
expect(message).toContain("Click the link to open the workspace:");
78-
expect(message).toContain("spawndock://spawn?token=pair_demo");
83+
expect(message).toContain("Project demo-app created.");
84+
expect(message).toContain("1. Run the bootstrap command locally:");
85+
expect(message).toContain("npx @spawn-dock/create --token pair_demo");
86+
expect(message).toContain("2. After bootstrap, run:");
87+
expect(message).toContain("pnpm run dev");
7988
});
8089

8190
it("includes TMA and preview links in launchMessage", () => {

src/bot/i18n.ts

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,47 @@ export function launchUsageMessage(locale: BotLocale): string {
9696
return "Use /launch <slug> to get the preview URL and current tunnel status.";
9797
}
9898

99-
export function createdMessage(locale: BotLocale, slug: string, spawnCmd: string, spawnLink: string): string {
99+
export function createdMessage(
100+
locale: BotLocale,
101+
slug: string,
102+
bootstrapCmd: string,
103+
previewUrl: string,
104+
telegramMiniAppUrl: string,
105+
tmaUrl: string,
106+
): string {
100107
if (locale === "ru") {
101108
return [
102-
`Проект <b>${esc(slug)}</b> создан.`,
109+
`Проект ${esc(slug)} создан.`,
110+
"",
111+
"1. Запусти bootstrap-команду локально:",
112+
`<code>${esc(bootstrapCmd)}</code>`,
113+
"",
114+
"Эту команду можно запускать повторно для этого проекта.",
103115
"",
104-
"Нажми на ссылку, чтобы открыть рабочее окружение:",
105-
renderLink(spawnLink),
116+
"2. После bootstrap запусти:",
117+
"<code>pnpm run dev</code>",
106118
"",
107-
"Или запусти команду локально в терминале:",
108-
`<code>${esc(spawnCmd)}</code>`
119+
"Ссылки:",
120+
`Preview URL: ${renderLink(previewUrl)}`,
121+
`Telegram Link: ${renderLink(telegramMiniAppUrl)}`,
122+
`TMA URL: ${renderLink(tmaUrl)}`,
109123
].join("\n");
110124
}
111125
return [
112-
`Project <b>${esc(slug)}</b> created.`,
126+
`Project ${esc(slug)} created.`,
127+
"",
128+
"1. Run the bootstrap command locally:",
129+
`<code>${esc(bootstrapCmd)}</code>`,
113130
"",
114-
"Click the link to open the workspace:",
115-
renderLink(spawnLink),
131+
"You can run this command again for the same project.",
116132
"",
117-
"Or run this command locally in your terminal:",
118-
`<code>${esc(spawnCmd)}</code>`
133+
"2. After bootstrap, run:",
134+
"<code>pnpm run dev</code>",
135+
"",
136+
"Links:",
137+
`Preview URL: ${renderLink(previewUrl)}`,
138+
`Telegram Link: ${renderLink(telegramMiniAppUrl)}`,
139+
`TMA URL: ${renderLink(tmaUrl)}`,
119140
].join("\n");
120141
}
121142

src/bot/polling.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,15 @@ async function processUpdate(cfg: ReturnType<typeof readBotConfig>, update: Tele
158158
clearTimeout(ackTimeout);
159159
const slug = data.project.slug;
160160
const token = data.pairingToken.token;
161-
const spawnCmd = `npx -y @spawn-dock/cli spawn --token ${token}`;
162-
const spawnLink = `spawndock://spawn?token=${token}`;
163-
await sendMessage(cfg.telegramBotToken, msg.chat.id, createdMessage(locale, slug, spawnCmd, spawnLink));
161+
const bootstrapCmd = `npx @spawn-dock/create --token ${token}`;
162+
const previewUrl = data.launchUrl;
163+
const tmaUrl = buildGatewayMiniAppUrl(previewUrl, slug);
164+
const telegramMiniAppUrl = buildTelegramMiniAppUrl(cfg.telegramBotUsername, cfg.telegramMiniAppShortName, slug);
165+
await sendMessage(
166+
cfg.telegramBotToken,
167+
msg.chat.id,
168+
createdMessage(locale, slug, bootstrapCmd, previewUrl, telegramMiniAppUrl, tmaUrl),
169+
);
164170
return;
165171
}
166172

0 commit comments

Comments
 (0)