school-portal-substitution-.../modules/config/config.go

36 lines
559 B
Go
Raw Normal View History

2022-06-30 19:06:37 +02:00
package config
import (
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
var Cfg Config
type Config struct {
Bot Bot
}
type Bot struct {
HomeserverUrl string `yaml:"homeserver_url"`
User string
Password string
RoomId string `yaml:"room_id"`
}
func LoadConfig() {
2022-06-30 19:34:57 +02:00
file, err := ioutil.ReadFile("../school-portal-substitution-plan-matrix-chat-bot/config.yaml")
2022-06-30 19:06:37 +02:00
if err != nil {
log.Fatalln("failed to load yaml file", err)
}
err = yaml.Unmarshal(file, &Cfg)
if err != nil {
log.Fatalln("failed to unmarshal config", err)
}
}