# The Noderunners Download Bot A Telegram bot that downloads video and audio from links, in private chats and in groups. Written in Go on top of yt-dlp. > Status: Phase 1 of 8 (core bot). Payments, the cache, remote workers, > group settings, the Mini App and more languages follow. See > [docs/ASSUMPTIONS.md](docs/ASSUMPTIONS.md) for the decisions made so far. ## What works today - Send a link in a private chat and get a card with title, thumbnail, duration and format buttons: Best, 720p, 480p, MP3, Thumbnail, Cancel. - In groups: `/dl `, or reply `/dl` to a message with a link. Buttons only work for the person who asked. - One status message, edited live: queued with position and wait, downloading with a progress bar, processing, sending, done. - A database backed queue with leases, one automatic retry and cancel. - Free tier limits: size, duration, one active job, bounded queue. - Friendly, translated error messages. Raw tool output stays in the logs. ## Quick start You need Go 1.26.11 or newer (older Go toolchains download it on their own), plus `yt-dlp` and `ffmpeg` on the PATH. ```sh # 1. Create a bot with @BotFather and copy its token. cp .env.example .env $EDITOR .env # set BOT_TOKEN # 2. Build and run. make build ./bin/core ``` Open your bot in Telegram, press Start and send it a link. To use the bot in a group, add it to the group. Group privacy mode can stay on: the bot only needs to see commands. ### Check that it is alive ```sh curl localhost:8080/healthz # {"status":"ok"} ``` ## Commands | Command | What it does | | --- | --- | | `/start` | Welcome message | | `/help` | Usage and your limits | | `/dl ` | Download a video. In groups also works as a reply to a link. | | `/audio ` | Download the audio as MP3 | | `/thumb ` | Send the thumbnail | | `/info ` | Show formats and sizes without downloading | | `/queue` | Your downloads in progress | | `/cancel` | Cancel your downloads | ## Configuration Everything is configured through environment variables. `.env.example` lists all of them with comments. A TOML file with the same settings is optional, see `config.example.toml`; the environment overrides the file. The settings you are most likely to touch: | Variable | Default | Meaning | | --- | --- | --- | | `BOT_TOKEN` | none | Token from @BotFather. Required. | | `TELEGRAM_MODE` | `polling` | `polling` or `webhook` | | `WORKER_CONCURRENCY` | `2` | Downloads running at the same time | | `FREE_MAX_SIZE_MB` | `50` | Size cap per download | | `FREE_MAX_DURATION` | `10m` | Duration cap per download | | `FREE_ACTIVE_JOBS` | `1` | Active downloads per user | | `QUEUE_FREE_MAX_LEN` | `20` | Most queued free jobs | | `DB_DSN` | `data/dlbot.db` | SQLite file | | `LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error` | ## Development ```sh make check # gofmt, go vet, tests with the race detector make test # tests only make e2e # real yt-dlp against a public test file, needs network ``` The tests need neither a bot token nor network access. They run the real bot against a fake Bot API server (`internal/tg/fakeserver`) and a scripted yt-dlp. ## Documentation - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): how the pieces fit. - [docs/ASSUMPTIONS.md](docs/ASSUMPTIONS.md): decisions and verified facts. ## Layout ``` cmd/core the bot gateway (and, for now, the embedded worker) internal/bot Telegram handlers, cards, status, delivery internal/service download rules shared by all front ends internal/sched the job queue internal/worker the download worker internal/ytdlp yt-dlp and ffprobe wrapper internal/db migrations and queries internal/storage file storage backends internal/i18n translations and formatting locales translation catalogs docs architecture and assumptions ```