Added a MediaUploadService option to the configuration loader and documented it in the README so operators can pick the attachment backend (defaulting to Litterbox) straight from .env.
All checks were successful
Build & Release / build-latest (push) Successful in 9m53s
Build & Release / version-release (push) Has been skipped

Refactored the Discord bridge to build a media service during initialization, route attachment uploads through it, and dynamically label the status embeds and error diagnostics based on the selected provider while preserving the existing progress messaging flow.

Introduced a new media package that defines the uploader interface and ships a Litterbox implementation responsible for fetching Discord attachments and posting them to Catbox while reporting HTTP status codes back to the bridge.
This commit is contained in:
Salastil
2025-11-18 17:33:42 -05:00
parent 93e875ffb7
commit f954771c0c
6 changed files with 316 additions and 81 deletions

36
media/service.go Normal file
View File

@@ -0,0 +1,36 @@
package media
import (
"context"
"fmt"
"net/http"
"strings"
"github.com/bwmarrin/discordgo"
)
const DefaultService = "litterbox"
// Service defines a pluggable uploader for Discord attachments.
type Service interface {
Name() string
Upload(ctx context.Context, attachment *discordgo.MessageAttachment) (url string, statusCode int, err error)
}
// NewService returns the configured media upload backend. Currently only
// Litterbox is supported but the hook point allows future expansion.
func NewService(name string, httpClient *http.Client) (Service, error) {
if httpClient == nil {
httpClient = &http.Client{}
}
normalized := strings.ToLower(strings.TrimSpace(name))
if normalized == "" {
normalized = DefaultService
}
switch normalized {
case DefaultService:
return &LitterboxService{client: httpClient}, nil
default:
return nil, fmt.Errorf("unknown media upload service: %s", name)
}
}