Phase 3: own referral system (sats)

- Referral links carry a random 8 character base32 code (rf_<code>)
  built from the bot username from getMe. Old ref_<id> links still work
  but are never shown.
- The reward (REFERRAL_REWARD_SATS, old name REFERRAL_REWARD still read)
  is paid through the ledger once the invited user's first purchase
  settles, once per invited user, never for self-referrals.
- REFERRAL_DAILY_CAP limits what an inviter earns per UTC day; rewards
  above it wait as pending and are paid on a later day by the billing
  loop.
- /referral shows invited, converted, earned and pending, with Share,
  Copy link and QR code buttons. The Mini App Me page mirrors it.
- Migration 00008: users.ref_code (unique) and referral_rewards,
  backfilled from earlier referral credits in the ledger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 20:58:43 +00:00
co-authored by Claude Opus 5.5
parent 123cede7f3
commit f7ceadc462
30 changed files with 945 additions and 148 deletions
+24 -19
View File
@@ -147,6 +147,9 @@ pick = "Elige un formato:"
cancelled = "Cancelado."
[btn]
qr = "Código QR"
copy_link = "Copiar enlace"
share = "Compartir"
maybe_over = "{{.Label}} ⚠"
remove_from_history = "Quitar del historial"
clear_yes = "Sí, borrarlo"
@@ -343,24 +346,6 @@ Descargas al mismo tiempo: {{.ActiveJobs}}
Descargas por día: {{.DailyDownloads}}
Volumen por día: {{.DailyVolume}}"""
[referral.text]
one = """
<b>Invita a tus amigos</b>
Comparte tu enlace. Cuando alguien que invitaste haga su primera compra, recibes {{.Reward}}.
{{.Link}}
Hasta ahora invitaste a {{.Count}} persona."""
other = """
<b>Invita a tus amigos</b>
Comparte tu enlace. Cuando alguien que invitaste haga su primera compra, recibes {{.Reward}}.
{{.Link}}
Hasta ahora invitaste a {{.Count}} personas."""
[redeem]
usage = "Envía el código después del comando.\nEjemplo: <code>/redeem NR-ABCD-EFGH-JKMN</code>"
invalid = "Ese código no es válido."
@@ -832,6 +817,10 @@ one = "Uso, último día"
other = "Uso, últimos {{.Count}} días"
[app.me]
qr = "Código QR"
pending = "En espera del tope diario"
earned = "Ganado"
converted = "Compraron algo"
downloads_title = "Descargas"
quality_note = "Con un formato por defecto, un enlace empieza enseguida en vez de preguntar."
audio_only = "Solo audio"
@@ -839,7 +828,7 @@ audio_only_hint = "Bajar siempre el sonido en MP3."
language_title = "Idioma"
language = "Idioma"
referral_title = "Invita a tus amigos"
referral_note = "Cuando alguien que invitaste haga su primera compra, recibes {{.Reward}}."
referral_note = "Cuando alguien que invitaste pague una primera compra en sats (Lightning), recibes {{.Reward}} en créditos."
copy_link = "Copiar enlace"
share = "Compartir"
invited = "Invitados hasta ahora"
@@ -885,3 +874,19 @@ other = "hace {{.Count}} días"
[history.clear_confirm]
one = "Quitar {{.Count}} descarga de tu historial? Los archivos que ya están en este chat se quedan donde están."
other = "Quitar las {{.Count}} descargas de tu historial? Los archivos que ya están en este chat se quedan donde están."
[referral]
qr_caption = """
Tu enlace de invitación como código QR:
{{.Link}}"""
share_text = "Descarga videos y música desde un enlace, directo en Telegram."
cap = "Ganas como máximo {{.Cap}} al día. Lo que pase de eso espera al día siguiente."
text = """
<b>Invita a tus amigos</b>
Comparte tu enlace. Cuando alguien que invitaste pague una primera compra en sats (Lightning), recibes {{.Reward}} en créditos.
{{.Link}}
Invitados: {{.Invited}} · Compraron algo: {{.Converted}}
Ganado: {{.Earned}} · En espera: {{.Pending}}"""