Fixed config loading, some formatting
This commit is contained in:
parent
687bef93c9
commit
e7afe60331
|
@ -9,39 +9,47 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.google.com/p/gcfg"
|
"code.google.com/p/gcfg"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DjConfig struct {
|
type DjConfig struct {
|
||||||
General struct {
|
General struct {
|
||||||
CommandPrefix string
|
CommandPrefix string
|
||||||
SkipRatio float32
|
SkipRatio float32
|
||||||
}
|
}
|
||||||
Volume struct {
|
Volume struct {
|
||||||
DefaultVolume float32
|
DefaultVolume float32
|
||||||
LowestVolume float32
|
LowestVolume float32
|
||||||
HighestVolume float32
|
HighestVolume float32
|
||||||
}
|
}
|
||||||
Aliases struct {
|
Aliases struct {
|
||||||
AddAlias string
|
AddAlias string
|
||||||
SkipAlias string
|
SkipAlias string
|
||||||
AdminSkipAlias string
|
AdminSkipAlias string
|
||||||
VolumeAlias string
|
VolumeAlias string
|
||||||
MoveAlias string
|
MoveAlias string
|
||||||
ReloadAlias string
|
ReloadAlias string
|
||||||
KillAlias string
|
KillAlias string
|
||||||
}
|
}
|
||||||
Permissions struct {
|
Permissions struct {
|
||||||
AdminsEnabled bool
|
AdminsEnabled bool
|
||||||
Admins []string
|
Admins []string
|
||||||
AdminAdd bool
|
AdminAdd bool
|
||||||
AdminSkip bool
|
AdminSkip bool
|
||||||
AdminVolume bool
|
AdminVolume bool
|
||||||
AdminMove bool
|
AdminMove bool
|
||||||
AdminReload bool
|
AdminReload bool
|
||||||
AdminKill bool
|
AdminKill bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfiguration() (error) {
|
func loadConfiguration() error {
|
||||||
return gcfg.ReadFileInto(&dj.conf, "mumbledj.gcfg")
|
usr, err := user.Current()
|
||||||
|
if err == nil {
|
||||||
|
return gcfg.ReadFileInto(&dj.conf, fmt.Sprintf("%s/.mumbledj/config/mumbledj.gcfg", usr.HomeDir))
|
||||||
|
} else {
|
||||||
|
return errors.New("Configuration load failed.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue