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
@@ -156,6 +156,9 @@ pick = "Pick a format:"
cancelled = "Cancelled."
[btn]
qr = "QR code"
copy_link = "Copy link"
share = "Share"
maybe_over = "{{.Label}} ⚠"
remove_from_history = "Remove from history"
clear_yes = "Yes, clear it"
@@ -357,24 +360,6 @@ Downloads at the same time: {{.ActiveJobs}}
Downloads per day: {{.DailyDownloads}}
Volume per day: {{.DailyVolume}}"""
[referral.text]
one = """
<b>Invite friends</b>
Share your link. When somebody you invited makes a first purchase, you get {{.Reward}}.
{{.Link}}
You invited {{.Count}} person so far."""
other = """
<b>Invite friends</b>
Share your link. When somebody you invited makes a first purchase, you get {{.Reward}}.
{{.Link}}
You invited {{.Count}} people so far."""
[redeem]
usage = "Send the code after the command.\nExample: <code>/redeem NR-ABCD-EFGH-JKMN</code>"
invalid = "That code is not valid."
@@ -857,6 +842,10 @@ one = "Usage, last day"
other = "Usage, last {{.Count}} days"
[app.me]
qr = "QR code"
pending = "Waiting for the daily cap"
earned = "Earned"
converted = "Bought something"
downloads_title = "Downloads"
quality_note = "With a default set, a link starts right away instead of asking for a format."
audio_only = "Audio only"
@@ -864,7 +853,7 @@ audio_only_hint = "Always fetch the sound as MP3."
language_title = "Language"
language = "Language"
referral_title = "Invite friends"
referral_note = "When somebody you invited makes a first purchase, you get {{.Reward}}."
referral_note = "When somebody you invited pays for a first purchase in sats (Lightning), you get {{.Reward}} in credits."
copy_link = "Copy link"
share = "Share"
invited = "Invited so far"
@@ -912,3 +901,19 @@ other = "{{.Count}} days ago"
[history.clear_confirm]
one = "Remove {{.Count}} download from your history? Files already in this chat stay where they are."
other = "Remove all {{.Count}} downloads from your history? Files already in this chat stay where they are."
[referral]
qr_caption = """
Your invite link as a QR code:
{{.Link}}"""
share_text = "Download videos and music from a link, right in Telegram."
cap = "You earn at most {{.Cap}} a day. Rewards above that wait for the next day."
text = """
<b>Invite friends</b>
Share your link. When somebody you invited pays for a first purchase in sats (Lightning), you get {{.Reward}} in credits.
{{.Link}}
Invited: {{.Invited}} · Bought something: {{.Converted}}
Earned: {{.Earned}} · Waiting: {{.Pending}}"""