hook2xmpp/config/main.go

48 lines
1.0 KiB
Go
Raw Normal View History

2017-06-09 10:55:47 +02:00
package config
import (
"io/ioutil"
"github.com/BurntSushi/toml"
"github.com/genofire/golang-lib/log"
)
type Config struct {
WebserverBind string `toml:"webserver_bind"`
XMPP struct {
Host string `toml:"host"`
Username string `toml:"username"`
Password string `toml:"password"`
Debug bool `toml:"debug"`
2017-06-09 15:51:04 +02:00
NoTLS bool `toml:"no_tls"`
Session bool `toml:"session"`
Status string `toml:"status"`
StatusMessage string `toml:"status_message"`
2017-06-09 10:55:47 +02:00
StartupNotify string `toml:"startup_notify"`
} `toml:"xmpp"`
Hooks []Hook `toml:"hooks"`
}
type Hook struct {
2017-06-10 16:07:23 +02:00
Type string `toml:"type"`
URL string `toml:"url"`
2017-06-09 10:55:47 +02:00
NotifyUser []string `toml:"notify_user"`
NotifyMuc []string `toml:"notify_muc"`
}
func ReadConfigFile(path string) *Config {
config := &Config{}
file, err := ioutil.ReadFile(path)
if err != nil {
log.Log.Panic(err)
}
if err := toml.Unmarshal(file, config); err != nil {
log.Log.Panic(err)
}
return config
}