Phase 1: core bot
Link in, card, download, send, in private chats and groups. - cmd/core with an embedded download worker - Telegram front end on telego v1.13.0 (Bot API 10.4): link card with thumbnail and format buttons, one live status message, /dl /audio /thumb /info /queue /cancel, group support with requester-only buttons - Database backed queue: paid and free lanes, leases with heartbeats, one automatic retry, cancel, queue position and wait estimate - yt-dlp and ffprobe behind a Runner interface with classified, redacted errors mapped to friendly messages - SQLite via modernc with goose migrations, portable schema - Local file storage behind a Storage interface - go-i18n with an English catalog, no literal text in handlers - Free tier limits enforced before queueing and again on the real file - Bot token and webhook secret are stripped from all log output - Tests: URL parsing, job lifecycle, worker, yt-dlp wrapper, and end to end flows against a fake Bot API server; opt-in test with the real yt-dlp Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# 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
|
||||
# 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=
|
||||
|
||||
# --- 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
|
||||
|
||||
# --- Worker -----------------------------------------------------------------
|
||||
# Run a download worker inside the core process.
|
||||
WORKER_EMBEDDED=true
|
||||
# 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
|
||||
|
||||
# --- Free tier limits -------------------------------------------------------
|
||||
FREE_MAX_SIZE_MB=50
|
||||
FREE_MAX_DURATION=10m
|
||||
FREE_ACTIVE_JOBS=1
|
||||
|
||||
# --- Logging ----------------------------------------------------------------
|
||||
# debug, info, warn or error.
|
||||
LOG_LEVEL=info
|
||||
# json or text.
|
||||
LOG_FORMAT=json
|
||||
Reference in New Issue
Block a user