Nik Afiq 0d58e46740
All checks were successful
CI / changes (push) Successful in 1s
CI / test (push) Successful in 6s
CI / build-ai-gateway (push) Has been skipped
CI / build-ha-gateway (push) Has been skipped
CI / build-discord-bot (push) Successful in 1m33s
CI / build-tts-gateway (push) Successful in 37s
CI / build-tts-sidecar (push) Has been skipped
feat: add /speak command for TTS integration
- Implemented the /speak command in Discord bot to synthesize speech using the TTS gateway.
- Added voice handling logic to join voice channels and play synthesized audio.
- Created tests for the new command and voice functionalities.
- Introduced TTSGateway interface for TTS service communication.
- Updated configuration to include TTS gateway address.
- Documented the TTS gateway integration and model artifact distribution process.
2026-07-25 02:09:02 +09:00

53 lines
1.4 KiB
Go

package config
import (
"errors"
"os"
)
// Config holds runtime configuration for the Discord bot process.
type Config struct {
DiscordToken string
GuildID string
HAGatewayAddr string
AIGatewayAddr string
TTSGatewayAddr string
TLSDir string
OTELEndpoint string
LogLevel string
LogFormat string
}
// Load reads Discord bot configuration from environment variables.
func Load() (*Config, error) {
token := os.Getenv("DISCORD_TOKEN")
if token == "" {
return nil, errors.New("DISCORD_TOKEN is required but not set")
}
addr := os.Getenv("HA_GATEWAY_ADDR")
if addr == "" {
return nil, errors.New("HA_GATEWAY_ADDR is required but not set")
}
return &Config{
DiscordToken: token,
GuildID: os.Getenv("GUILD_ID"),
HAGatewayAddr: addr,
AIGatewayAddr: getenvDefault("AI_GATEWAY_ADDR", "ai-gateway.home-services.svc.cluster.local:50052"),
TTSGatewayAddr: getenvDefault("TTS_GATEWAY_ADDR", "tts-gateway.home-services.svc.cluster.local:50053"),
TLSDir: os.Getenv("TLS_DIR"),
OTELEndpoint: os.Getenv("OTEL_ENDPOINT"),
LogLevel: getenvDefault("LOG_LEVEL", "info"),
LogFormat: getenvDefault("LOG_FORMAT", "json"),
}, nil
}
// getenvDefault keeps config loading concise for optional variables with defaults.
func getenvDefault(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}