32 lines
584 B
Go
32 lines
584 B
Go
|
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
|
||
|
}
|