- Added command handler for processing Discord interactions related to lights and switches. - Implemented command registration for light control commands: list, on, off, and toggle. - Created a gRPC client for communicating with the home automation gateway. - Developed application logic for handling light and switch commands, including listing, turning on/off, and toggling lights. - Introduced telemetry setup for OpenTelemetry integration. - Added configuration loading for Discord token, gateway address, and OpenTelemetry endpoint. - Defined core driven ports for interacting with the home automation gateway.
33 lines
598 B
Go
33 lines
598 B
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
DiscordToken string
|
|
GuildID string
|
|
HAGatewayAddr string
|
|
OTELEndpoint string
|
|
}
|
|
|
|
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,
|
|
OTELEndpoint: os.Getenv("OTEL_ENDPOINT"),
|
|
}, nil
|
|
}
|