- Stars as a second payment method for passes and credit packs, next to Lightning (STARS_ENABLED, prices in [stars_prices] / STARS_PRICES, set on their own). Invoices in XTR with no provider token and one price; pre-checkout checks payer, state, currency and amount; successful_payment settles through the same transaction as Lightning, so entitlement is identical. Idempotent by telegram_payment_charge_id (unique index). - Migration 00009: payment_method on purchases and ledger entries, plus stars_amount, tg_charge_id and refunded_at on purchases. Stars purchases never reach LNbits. - Chat: buy screen, /credits, /account and the over-limit offer show Lightning first and a Pay with Stars button. - Mini App: Lightning and Stars switch on Buy; Stars use createInvoiceLink and WebApp.openInvoice, confirmed by the server-side payment event. - Owner /refund <purchase or charge ID> calls refundStarPayment and takes back the credits or pass; refunded_payment messages do the same once. /stats shows revenue by payment method. - The sats referral reward counts Lightning purchases only. - The bot now asks Telegram for pre_checkout_query updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
239 lines
9.1 KiB
Bash
239 lines
9.1 KiB
Bash
# Copy to .env and fill in. The core reads .env from its working directory
|
|
# and never overrides variables that are already set in the environment.
|
|
# Structured settings can also live in a TOML file, see config.example.toml.
|
|
|
|
# --- Telegram ---------------------------------------------------------------
|
|
# Token from @BotFather. Required.
|
|
BOT_TOKEN=
|
|
# Bot API root. Point it at a local Bot API server to send files up to 2 GB.
|
|
TELEGRAM_API_URL=https://api.telegram.org
|
|
# polling (default) or webhook.
|
|
TELEGRAM_MODE=polling
|
|
# Prometheus metrics at /metrics on HTTP_LISTEN. Keep the path off the
|
|
# public internet; see docs/MONITORING.md.
|
|
METRICS_ENABLED=true
|
|
|
|
# Public HTTPS base URL of this server. Only for webhook mode. Telegram will
|
|
# call <WEBHOOK_URL>/telegram/webhook.
|
|
WEBHOOK_URL=
|
|
# Random string Telegram echoes back in a header. Only for webhook mode.
|
|
WEBHOOK_SECRET=
|
|
# Largest file the bot can send, in MB. 50 on the cloud Bot API.
|
|
TELEGRAM_MAX_UPLOAD_MB=50
|
|
# Goroutines that handle updates.
|
|
TELEGRAM_UPDATE_WORKERS=8
|
|
|
|
# Telegram user IDs allowed to use owner commands, comma separated.
|
|
OWNER_IDS=
|
|
|
|
# Public HTTPS base URL of this server, without a trailing slash. Used for
|
|
# payment webhooks, "open in wallet" links and the Mini App. Payments work
|
|
# without it (invoices are then settled by polling only).
|
|
PUBLIC_URL=
|
|
|
|
# The Mini App: downloads, queue, shop, groups and settings inside Telegram.
|
|
# Needs PUBLIC_URL with https, and one setting in @BotFather, see
|
|
# docs/OPERATIONS.md. The app is served by the core under <PUBLIC_URL>/app/.
|
|
MINIAPP_ENABLED=false
|
|
|
|
# Set the bot's name, description and short description in every language
|
|
# from the catalogs (profile.* in locales/*.toml). false keeps whatever is
|
|
# set in @BotFather.
|
|
TELEGRAM_SET_PROFILE=true
|
|
|
|
# Show the download status and invoices as live HTML widgets in private
|
|
# chats (Bot API 10.4 sendWidget): a progress bar with a cancel button, and
|
|
# an invoice with a QR code, a countdown and its paid state. If Telegram
|
|
# refuses a widget the bot sends the ordinary message instead, by itself.
|
|
TELEGRAM_WIDGETS=true
|
|
|
|
# --- Chat flow ----------------------------------------------------------------
|
|
# A queued download shows its position and wait only when the expected wait
|
|
# is above this many seconds or it is not first in line. Otherwise the
|
|
# status simply says it is downloading.
|
|
QUEUE_NOTICE_THRESHOLD_SECONDS=10
|
|
# How many links of one message are handled, each with its own status.
|
|
MULTI_LINK_MAX=5
|
|
# Add a "via @botname" line under the caption of every file the bot sends.
|
|
CAPTION_ATTRIBUTION=true
|
|
|
|
# Add the pseudo-locale en-XA (accented, bracketed English) for checking
|
|
# that every text comes from the catalog. Only owners can pick it.
|
|
I18N_PSEUDO=false
|
|
|
|
# Where /support sends users: a @username or a link.
|
|
SUPPORT_CONTACT=
|
|
# Load translations from this directory instead of the built-in ones, and
|
|
# let "/reload i18n" pick up edits.
|
|
LOCALES_DIR=
|
|
|
|
# --- HTTP -------------------------------------------------------------------
|
|
# Listen address of the health endpoint and the webhook.
|
|
HTTP_LISTEN=:8080
|
|
|
|
# --- Database ---------------------------------------------------------------
|
|
# sqlite or postgres.
|
|
DB_DRIVER=sqlite
|
|
# File path for sqlite, connection URL for postgres.
|
|
DB_DSN=data/dlbot.db
|
|
|
|
# --- Storage ----------------------------------------------------------------
|
|
# local or s3.
|
|
STORAGE_BACKEND=local
|
|
STORAGE_LOCAL_DIR=data/files
|
|
|
|
# S3 compatible bucket (AWS S3, Garage, MinIO). Only for STORAGE_BACKEND=s3.
|
|
# The bucket must exist.
|
|
S3_ENDPOINT=
|
|
S3_BUCKET=
|
|
S3_ACCESS_KEY=
|
|
S3_SECRET_KEY=
|
|
S3_REGION=garage
|
|
S3_USE_SSL=true
|
|
# /bucket/key addressing. Garage and MinIO: true. AWS: false.
|
|
S3_PATH_STYLE=true
|
|
# Optional key prefix, to share a bucket.
|
|
S3_PREFIX=
|
|
# Workers upload straight to the bucket with presigned URLs.
|
|
S3_PRESIGN=true
|
|
# Address workers reach the bucket at, if not S3_ENDPOINT.
|
|
S3_PRESIGN_ENDPOINT=
|
|
|
|
# --- Scale out --------------------------------------------------------------
|
|
# Remote workers registered at startup, as name:token pairs. Tokens are any
|
|
# random string of 16 characters or more. docker-compose.yml builds this
|
|
# from WORKER_A_TOKEN and WORKER_B_TOKEN. "core worker add <name>" creates
|
|
# tokens without a restart. See docs/WORKERS.md.
|
|
WORKER_TOKENS=
|
|
# Tokens of the two workers in docker-compose.yml: openssl rand -hex 24
|
|
WORKER_A_TOKEN=
|
|
WORKER_B_TOKEN=
|
|
# Their tags, for example residential,eu.
|
|
WORKER_A_TAGS=
|
|
WORKER_B_TAGS=
|
|
# Which worker tags a site requires: host=tag,tag;host=tag
|
|
# A host covers its subdomains. Example: youtube.com=residential
|
|
SITE_TAGS=
|
|
# Who looks links up for the card: auto, local (the core) or worker.
|
|
PROBE_MODE=auto
|
|
|
|
# --- Worker (the one inside the core) ---------------------------------------
|
|
# Run a download worker inside the core process.
|
|
WORKER_EMBEDDED=true
|
|
# Tags of the embedded worker.
|
|
WORKER_TAGS=
|
|
# Downloads running at the same time.
|
|
WORKER_CONCURRENCY=2
|
|
# Scratch space for downloads. Each worker process needs its own directory.
|
|
WORKER_TEMP_DIR=data/tmp
|
|
YTDLP_PATH=yt-dlp
|
|
FFMPEG_PATH=ffmpeg
|
|
# Hard cap for one download attempt.
|
|
DOWNLOAD_TIMEOUT=30m
|
|
# Cap for one metadata lookup, and how many may run at once.
|
|
PROBE_TIMEOUT=45s
|
|
PROBE_CONCURRENCY=4
|
|
|
|
# --- Queue ------------------------------------------------------------------
|
|
# Most queued jobs accepted from free users.
|
|
QUEUE_FREE_MAX_LEN=20
|
|
# A claimed job goes back to the queue when no heartbeat arrives for this long.
|
|
QUEUE_LEASE=30s
|
|
QUEUE_HEARTBEAT=10s
|
|
# Tries per job. 2 means one automatic retry.
|
|
QUEUE_MAX_ATTEMPTS=2
|
|
|
|
# --- Cache ------------------------------------------------------------------
|
|
# The cache only makes repeat downloads faster. It never changes limits.
|
|
CACHE_ENABLED=true
|
|
# Largest total size of stored copies, in MB. 0 means no cap.
|
|
CACHE_BUDGET_MB=20000
|
|
# How long a result is served before it is fetched again, by kind of site.
|
|
CACHE_TTL=168h
|
|
CACHE_TTL_STABLE=720h
|
|
CACHE_TTL_EPHEMERAL=6h
|
|
# yt-dlp extractor name prefixes for the two special classes.
|
|
CACHE_STABLE_SITES=youtube,vimeo,archive.org,soundcloud,dailymotion,peertube,bandcamp
|
|
CACHE_EPHEMERAL_SITES=twitter,instagram,tiktok,facebook,reddit,twitch,generic
|
|
# How long link metadata is remembered, so cards for known links are instant.
|
|
CACHE_META_TTL=30m
|
|
# Make lower qualities and audio from a stored copy with ffmpeg instead of
|
|
# downloading again.
|
|
CACHE_DERIVE=true
|
|
CACHE_SWEEP_INTERVAL=10m
|
|
|
|
# --- Free tier limits -------------------------------------------------------
|
|
FREE_MAX_SIZE_MB=50
|
|
FREE_MAX_DURATION=10m
|
|
FREE_ACTIVE_JOBS=1
|
|
# Per UTC day. 0 means no cap.
|
|
FREE_DAILY_DOWNLOADS=5
|
|
FREE_DAILY_MB=250
|
|
# Items fetched from one playlist link.
|
|
FREE_PLAYLIST_ITEMS=3
|
|
|
|
# --- Paid limits (passes, credits, one-off payments) ------------------------
|
|
# Sizes above TELEGRAM_MAX_UPLOAD_MB need a local Bot API server.
|
|
PAID_MAX_SIZE_MB=2000
|
|
PAID_MAX_DURATION=3h
|
|
PAID_ACTIVE_JOBS=3
|
|
PAID_DAILY_DOWNLOADS=100
|
|
# The daily volume cap applies to paying users too.
|
|
PAID_DAILY_MB=20000
|
|
PAID_PLAYLIST_ITEMS=25
|
|
|
|
# --- Payments (LNbits) ------------------------------------------------------
|
|
# Leave LNBITS_URL and LNBITS_INVOICE_KEY empty to run without payments.
|
|
LNBITS_URL=
|
|
# The wallet's INVOICE key (read only). Never give the bot the admin key.
|
|
LNBITS_INVOICE_KEY=
|
|
# Random string. It becomes part of the webhook path that LNbits calls:
|
|
# <PUBLIC_URL>/lnbits/webhook/<LNBITS_WEBHOOK_SECRET>
|
|
LNBITS_WEBHOOK_SECRET=
|
|
# How often unsettled invoices are checked, as a fallback for lost webhooks.
|
|
LNBITS_POLL_INTERVAL=5s
|
|
# How long an invoice can be paid.
|
|
INVOICE_EXPIRY=10m
|
|
|
|
# --- Prices in sats ---------------------------------------------------------
|
|
PRICE_PASS_DAY=700
|
|
PRICE_PASS_WEEK=3000
|
|
PRICE_PASS_MONTH=9000
|
|
# Cost of one download when credits pay.
|
|
PRICE_CREDIT_DOWNLOAD=50
|
|
# "Pay for this file only": base plus a step per started 100 MB.
|
|
PRICE_ONE_OFF_BASE=100
|
|
PRICE_ONE_OFF_PER_100MB=50
|
|
# Moving one waiting free job to the priority lane.
|
|
PRICE_SKIP_QUEUE=50
|
|
# Top-up and tip amounts offered as buttons.
|
|
CREDIT_PACKS=1000,5000,20000
|
|
DONATION_AMOUNTS=500,2100,10000
|
|
# --- Referrals (Lightning) ------------------------------------------------------
|
|
# Credited to the inviter when somebody they invited settles a first
|
|
# Lightning purchase. 0 turns the reward off. (The older name
|
|
# REFERRAL_REWARD still works; this one wins when both are set.)
|
|
REFERRAL_REWARD_SATS=200
|
|
# The most one inviter earns per day (UTC), in sats. Rewards above it wait
|
|
# and are paid on a later day. 0 means no cap.
|
|
REFERRAL_DAILY_CAP=2000
|
|
|
|
# --- Telegram Stars ---------------------------------------------------------------
|
|
# Offer Telegram Stars as a second way to pay for passes and credit packs,
|
|
# next to Lightning. Needs nothing in @BotFather. Stars prices are set on
|
|
# their own, never converted from sats; a product without a price is not
|
|
# sold for Stars. Keys: pass_day, pass_week, pass_month, credits_<sats>.
|
|
STARS_ENABLED=false
|
|
STARS_PRICES=pass_day=50,pass_week=200,pass_month=600,credits_1000=70,credits_5000=330,credits_20000=1300
|
|
|
|
# --- Rate limits ------------------------------------------------------------
|
|
# Links per minute. 0 means no limit.
|
|
RATE_USER_PER_MINUTE=10
|
|
RATE_GROUP_PER_MINUTE=30
|
|
|
|
# --- Logging ----------------------------------------------------------------
|
|
# debug, info, warn or error.
|
|
LOG_LEVEL=info
|
|
# json or text.
|
|
LOG_FORMAT=json
|