summaryrefslogtreecommitdiffstats
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 00000000..17d4bbd8
--- /dev/null
+++ b/config.go
@@ -0,0 +1,35 @@
+package main
+
+import (
+ "gopkg.in/gcfg.v1"
+ "io/ioutil"
+ "log"
+)
+
+type Config struct {
+ IRC struct {
+ UseTLS bool
+ SkipTLSVerify bool
+ Server string
+ Port int
+ Nick string
+ Channel string
+ }
+ Mattermost struct {
+ URL string
+ Port int
+ }
+}
+
+func NewConfig(cfgfile string) *Config {
+ var cfg Config
+ content, err := ioutil.ReadFile(cfgfile)
+ if err != nil {
+ log.Fatal(err)
+ }
+ err = gcfg.ReadStringInto(&cfg, string(content))
+ if err != nil {
+ log.Fatal("Failed to parse "+cfgfile+":", err)
+ }
+ return &cfg
+}