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,36 @@
|
||||
// Package storage keeps downloaded files. Backends are chosen by
|
||||
// configuration and share one interface.
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ErrNotFound is returned when a key does not exist.
|
||||
var ErrNotFound = errors.New("storage: not found")
|
||||
|
||||
// Object describes a stored file.
|
||||
type Object struct {
|
||||
Key string
|
||||
Size int64
|
||||
ModTime time.Time
|
||||
}
|
||||
|
||||
// Storage is a flat key to file store. Keys use forward slashes and never
|
||||
// start with one, for example "jobs/01abc/media.mp4".
|
||||
type Storage interface {
|
||||
// Put stores r under key, replacing any previous content. size may be -1
|
||||
// when unknown.
|
||||
Put(ctx context.Context, key string, r io.Reader, size int64) error
|
||||
// Open returns a reader for key and the size in bytes.
|
||||
Open(ctx context.Context, key string) (io.ReadCloser, int64, error)
|
||||
// Stat returns the object details without reading it.
|
||||
Stat(ctx context.Context, key string) (Object, error)
|
||||
// Delete removes key. Deleting a missing key is not an error.
|
||||
Delete(ctx context.Context, key string) error
|
||||
// List calls fn for every object whose key starts with prefix.
|
||||
List(ctx context.Context, prefix string, fn func(Object) error) error
|
||||
}
|
||||
Reference in New Issue
Block a user