Phase 5: Telegram affiliate program

- docs/AFFILIATE.md: the owner's setup in Telegram (profile editor or
  BotFather's Mini App), commission and duration rules (raise only, end
  with commission 0, about 24 hours), who counts as referred, the link
  formats, and the no-double-rewards rule. Checked against Telegram's
  current pages.
- Affiliate purchases go through Stars invoices inside the Mini App
  (createInvoiceLink and WebApp.openInvoice, from Phase 4).
- /start accepts any payload; only our own rf_ (and old ref_) links set
  an inviter. A test sends payloads of every shape, Telegram's affiliate
  prefix included.
- Mini App Me page: an Earn section explaining both programs, with how
  to join Telegram's from the bot's profile, behind AFFILIATE_ENABLED.
  No affiliate numbers are computed or shown.
- /referral notes that Stars purchases earn through Telegram's program.
- The optional MTProto CLI is left out, with the reason in the docs.
- The Mini App browser test checks the Earn section in en, es and nl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 21:31:06 +00:00
co-authored by Claude Opus 5.5
parent 2b5625e9d4
commit d64db03f21
20 changed files with 341 additions and 9 deletions
+13 -1
View File
@@ -220,7 +220,14 @@ try {
await page.locator('[role="switch"][aria-checked="true"]').waitFor();
await page.getByRole("button", { name: "Copy link" }).click();
const link = await page.evaluate(() => navigator.clipboard.readText());
if (!/\?start=ref_\d+$/.test(link)) throw new Error("referral link = " + link);
if (!/\?start=rf_[A-Z2-7]{8}$/.test(link)) throw new Error("referral link = " + link);
// Both ways to earn are explained: our sats referral and Telegram's
// affiliate program, which the app only describes.
await page.getByText("Earn", { exact: true }).waitFor();
await page.getByText("Telegram affiliate program", { exact: true }).waitFor();
await page.getByRole("button", { name: "Open the bot's profile" }).click();
const profile = await page.evaluate(() => window.__opened.at(-1));
if (!/^https:\/\/t\.me\/[A-Za-z0-9_]+$/.test(profile || "")) throw new Error("profile link = " + profile);
await page.getByRole("button", { name: "Share" }).click();
const shared = await page.evaluate(() => window.__opened.at(-1));
if (!shared.startsWith("https://t.me/share/url?url=")) throw new Error("share link = " + shared);
@@ -230,10 +237,15 @@ try {
await page.getByLabel("Language", { exact: true }).selectOption("es");
await tab(page, "Inicio").waitFor();
await page.getByText("Invita a tus amigos").waitFor();
await page.getByText("Gana", { exact: true }).waitFor();
await page.getByText("Programa de afiliados de Telegram", { exact: true }).waitFor();
if ((await page.evaluate(() => document.documentElement.lang)) !== "es") throw new Error("html lang was not updated");
await shot(page, "me-spanish");
await page.getByLabel("Idioma", { exact: true }).selectOption("nl");
await tab(page, "Start").waitFor();
await page.getByText("Verdienen", { exact: true }).waitFor();
await page.getByText("Affiliateprogramma van Telegram", { exact: true }).waitFor();
await shot(page, "me-dutch");
await page.getByLabel("Taal", { exact: true }).selectOption("");
await tab(page, "Home").waitFor();
});