965cce7192
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package config
|
|
|
|
import "os"
|
|
|
|
// Config holds Platform Bridge configuration.
|
|
type Config struct {
|
|
Port string
|
|
Env string
|
|
GatewayURL string
|
|
AICoreURL string
|
|
InternalToken string
|
|
|
|
// Platform-specific.
|
|
QQBotPort string // port for QQ OBv11 reverse WebSocket
|
|
TelegramToken string // Telegram Bot API token
|
|
TelegramWebhookURL string // public webhook URL for Telegram
|
|
}
|
|
|
|
func Load() *Config {
|
|
cfg := &Config{
|
|
Port: "8095",
|
|
Env: "development",
|
|
GatewayURL: "http://localhost:8080",
|
|
AICoreURL: "http://localhost:8081",
|
|
QQBotPort: "8096",
|
|
}
|
|
if v := os.Getenv("PORT"); v != "" {
|
|
cfg.Port = v
|
|
}
|
|
if v := os.Getenv("ENV"); v != "" {
|
|
cfg.Env = v
|
|
}
|
|
if v := os.Getenv("GATEWAY_URL"); v != "" {
|
|
cfg.GatewayURL = v
|
|
}
|
|
if v := os.Getenv("AI_CORE_URL"); v != "" {
|
|
cfg.AICoreURL = v
|
|
}
|
|
if v := os.Getenv("INTERNAL_SERVICE_TOKEN"); v != "" {
|
|
cfg.InternalToken = v
|
|
}
|
|
if v := os.Getenv("QQ_BOT_PORT"); v != "" {
|
|
cfg.QQBotPort = v
|
|
}
|
|
if v := os.Getenv("TELEGRAM_BOT_TOKEN"); v != "" {
|
|
cfg.TelegramToken = v
|
|
}
|
|
if v := os.Getenv("TELEGRAM_WEBHOOK_URL"); v != "" {
|
|
cfg.TelegramWebhookURL = v
|
|
}
|
|
return cfg
|
|
}
|