This repository has been archived on 2019-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mumbledj/parseconfig.go

56 lines
1,009 B
Go
Raw Normal View History

2014-12-13 05:52:44 +01:00
/*
* MumbleDJ
* By Matthieu Grieger
* parseconfig.go
* Copyright (c) 2014 Matthieu Grieger (MIT License)
*/
package main
import (
"code.google.com/p/gcfg"
2014-12-16 01:41:15 +01:00
"errors"
"fmt"
"os/user"
2014-12-13 05:52:44 +01:00
)
type DjConfig struct {
General struct {
CommandPrefix string
2014-12-16 01:41:15 +01:00
SkipRatio float32
}
Volume struct {
DefaultVolume float32
2014-12-16 01:41:15 +01:00
LowestVolume float32
HighestVolume float32
}
Aliases struct {
2014-12-16 01:41:15 +01:00
AddAlias string
SkipAlias string
AdminSkipAlias string
2014-12-16 01:41:15 +01:00
VolumeAlias string
MoveAlias string
ReloadAlias string
KillAlias string
}
Permissions struct {
AdminsEnabled bool
2014-12-16 01:41:15 +01:00
Admins []string
AdminAdd bool
AdminSkip bool
AdminVolume bool
AdminMove bool
AdminReload bool
AdminKill bool
}
2014-12-13 05:52:44 +01:00
}
2014-12-16 01:41:15 +01:00
func loadConfiguration() error {
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.")
}
2014-12-13 05:52:44 +01:00
}