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.
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:
@@ -10,16 +10,17 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
DiscordBotToken string
|
||||
DiscordChannelID string
|
||||
DiscordGuildID string
|
||||
DiscordWebhookURL string
|
||||
SneedchatRoomID int
|
||||
BridgeUsername string
|
||||
BridgePassword string
|
||||
BridgeUserID int
|
||||
DiscordPingUserID string
|
||||
Debug bool
|
||||
DiscordBotToken string
|
||||
DiscordChannelID string
|
||||
DiscordGuildID string
|
||||
DiscordWebhookURL string
|
||||
SneedchatRoomID int
|
||||
MediaUploadService string
|
||||
BridgeUsername string
|
||||
BridgePassword string
|
||||
BridgeUserID int
|
||||
DiscordPingUserID string
|
||||
Debug bool
|
||||
}
|
||||
|
||||
func Load(envFile string) (*Config, error) {
|
||||
@@ -27,13 +28,17 @@ func Load(envFile string) (*Config, error) {
|
||||
log.Printf("Warning: error loading %s: %v", envFile, err)
|
||||
}
|
||||
cfg := &Config{
|
||||
DiscordBotToken: os.Getenv("DISCORD_BOT_TOKEN"),
|
||||
DiscordChannelID: os.Getenv("DISCORD_CHANNEL_ID"),
|
||||
DiscordGuildID: os.Getenv("DISCORD_GUILD_ID"),
|
||||
DiscordWebhookURL: os.Getenv("DISCORD_WEBHOOK_URL"),
|
||||
BridgeUsername: os.Getenv("BRIDGE_USERNAME"),
|
||||
BridgePassword: os.Getenv("BRIDGE_PASSWORD"),
|
||||
DiscordPingUserID: os.Getenv("DISCORD_PING_USER_ID"),
|
||||
DiscordBotToken: os.Getenv("DISCORD_BOT_TOKEN"),
|
||||
DiscordChannelID: os.Getenv("DISCORD_CHANNEL_ID"),
|
||||
DiscordGuildID: os.Getenv("DISCORD_GUILD_ID"),
|
||||
DiscordWebhookURL: os.Getenv("DISCORD_WEBHOOK_URL"),
|
||||
MediaUploadService: os.Getenv("MEDIA_UPLOAD_SERVICE"),
|
||||
BridgeUsername: os.Getenv("BRIDGE_USERNAME"),
|
||||
BridgePassword: os.Getenv("BRIDGE_PASSWORD"),
|
||||
DiscordPingUserID: os.Getenv("DISCORD_PING_USER_ID"),
|
||||
}
|
||||
if cfg.MediaUploadService == "" {
|
||||
cfg.MediaUploadService = "litterbox"
|
||||
}
|
||||
roomID, err := strconv.Atoi(os.Getenv("SNEEDCHAT_ROOM_ID"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user