aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorNathan Perry <avaglir@gmail.com>2017-07-26 20:00:31 -0400
committerNathan Perry <avaglir@gmail.com>2017-07-26 20:00:31 -0400
commitf3224ee0eb4d5def781f5e77121a405df054bfba (patch)
treec9f0e4f864168afeb3119ece86014819bfe4b512 /util.go
parentfa3151827fa697c91802b09ae0052429e788b275 (diff)
restructure to cmd
Diffstat (limited to 'util.go')
-rw-r--r--util.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..ae4ca2c
--- /dev/null
+++ b/util.go
@@ -0,0 +1,37 @@
+package thulani
+
+import (
+ "encoding/json"
+ "os"
+
+ "github.com/op/go-logging"
+)
+
+func handle(err error) {
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+var log = logging.MustGetLogger("thulani")
+
+type Config struct {
+ Trigger string `json:"trigger"`
+ QueueSize uint `json:"queue_size"`
+ Admin uint `json:"admin"`
+ OpRole string `json:"op_role"`
+ Server string `json:"server"`
+ VoiceChannel string `json:"voice_channel"`
+ Token string `json:"token"`
+}
+
+func LoadConfig(filename string) (*Config, error) {
+ file, err := os.Open("config.json")
+ if err != nil {
+ return nil, err
+ }
+
+ var conf Config
+ err = json.NewDecoder(file).Decode(&conf)
+ return &conf, err
+}