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:
Michilis
2026-11-18 07:33:32 +00:00
co-authored by Claude Fable 5.2
commit 3b361c17a1
63 changed files with 10715 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
// Command core is the bot gateway: it talks to Telegram, owns the queue and
// the database, serves the HTTP API and, by default, runs an embedded
// download worker.
package main
import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/noderunners/dlbot/internal/app"
"github.com/noderunners/dlbot/internal/config"
)
func main() {
configPath := flag.String("config", "", "path to a TOML config file (optional, env vars override it)")
flag.Parse()
cfg, err := config.Load(*configPath)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
log := app.NewLogger(cfg.Log, app.Secrets(cfg)...)
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
a, err := app.New(ctx, app.Options{Config: cfg, Log: log})
if err != nil {
log.Error("startup failed", "err", err)
os.Exit(1)
}
if err := a.Run(ctx); err != nil {
log.Error("core exited with error", "err", err)
os.Exit(1)
}
}