nunbot/config.go

32 lines
584 B
Go
Raw Normal View History

2022-07-13 15:07:01 -04:00
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type botConfig struct {
Homeserver string `yaml:"homeserver"`
Domain string `yaml:"domain"`
Dimension string `yaml:"dimension"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Statefile string `yaml:"statefile"`
Token string `yaml:"token"`
}
func loadConfig(filename string) *botConfig {
yamlFile, err := ioutil.ReadFile(filename)
cnf := &botConfig{}
if err == nil {
err = yaml.Unmarshal(yamlFile, cnf)
} else {
panic(err)
}
if err != nil {
panic(err)
}
return cnf
}