More changes to config, not working yet

This commit is contained in:
Matthieu Grieger 2014-12-13 09:47:42 -08:00
parent 0629776b81
commit bc4091f639
3 changed files with 9 additions and 16 deletions

View file

@ -59,6 +59,8 @@ func parseCommand(username, command string) {
if success { if success {
fmt.Println("Kill successful!") fmt.Println("Kill successful!")
} }
case "test":
fmt.Printf("Title: %s\n", dj.conf.title)
} }
} }

View file

@ -21,7 +21,7 @@ type mumbledj struct {
client *gumble.Client client *gumble.Client
keepAlive chan bool keepAlive chan bool
defaultChannel string defaultChannel string
conf config conf djConfig
} }
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) { func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {

View file

@ -9,12 +9,10 @@ package main
import ( import (
"errors" "errors"
"fmt"
"io/ioutil"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
) )
type config struct { type djConfig struct {
title string title string
general generalConfig general generalConfig
volume volumeConfig volume volumeConfig
@ -55,17 +53,10 @@ type permissionsConfig struct {
adminKill bool `toml:"admin_kill"` adminKill bool `toml:"admin_kill"`
} }
func loadConfiguration() (config, error) { func loadConfiguration() (djConfig, error) {
file, err := ioutil.ReadFile("config.toml") var conf djConfig
if err != nil { if _, err := toml.DecodeFile("config.toml", &conf); err != nil {
panic(err) return conf, errors.New("Configuration load failed.")
} else {
fileString := string(file)
var conf config
if _, err := toml.Decode(fileString, &conf); err != nil {
return conf, errors.New("Configuration load failed.")
}
return conf, nil
} }
return conf, nil
} }