irc_bot/config.go

34 lines
729 B
Go

package main
import (
"encoding/json"
"os"
)
type Config struct {
IRCServer string `json:"irc_server"`
IRCPort int `json:"irc_port"`
SSL bool `json:"ssl"`
Nickname string `json:"nickname"`
Channels []string `json:"channels"`
GeoIPDatabase string `json:"geoip_database"`
GeoIPASN string `json:"geoip_asn"`
}
func LoadConfig(filePath string) (*Config, error) {
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()
config := &Config{}
decoder := json.NewDecoder(file)
err = decoder.Decode(config)
if err != nil {
return nil, err
}
return config, nil
}