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

90 lines
2.2 KiB
Go
Raw Normal View History

2014-12-13 05:52:44 +01:00
/*
* MumbleDJ
* By Matthieu Grieger
* parseconfig.go
2015-01-18 23:44:40 +01:00
* Copyright (c) 2014, 2015 Matthieu Grieger (MIT License)
2014-12-13 05:52:44 +01:00
*/
package main
import (
2014-12-16 01:41:15 +01:00
"errors"
"fmt"
2015-04-09 22:23:21 +02:00
"code.google.com/p/gcfg"
2014-12-13 05:52:44 +01:00
)
2015-05-10 07:00:24 +02:00
// DjConfig is a Golang struct representation of mumbledj.gcfg file structure for parsing.
type DjConfig struct {
General struct {
CommandPrefix string
SkipRatio float32
PlaylistSkipRatio float32
DefaultComment string
MaxSongDuration int
AutomaticShuffleOn bool
}
Cache struct {
Enabled bool
MaximumSize int64
ExpireTime float64
}
Volume struct {
DefaultVolume float32
2014-12-16 01:41:15 +01:00
LowestVolume float32
HighestVolume float32
}
Aliases struct {
AddAlias string
SkipAlias string
SkipPlaylistAlias string
AdminSkipAlias string
AdminSkipPlaylistAlias string
2015-01-11 00:15:12 +01:00
HelpAlias string
VolumeAlias string
MoveAlias string
ReloadAlias string
2015-01-06 04:16:59 +01:00
ResetAlias string
NumSongsAlias string
2015-01-13 01:21:53 +01:00
NextSongAlias string
2015-01-25 20:27:28 +01:00
CurrentSongAlias string
SetCommentAlias string
NumCachedAlias string
CacheSizeAlias string
KillAlias string
2015-10-09 21:49:56 +02:00
ShuffleAlias string
ShuffleOnAlias string
ShuffleOffAlias string
}
Permissions struct {
AdminsEnabled bool
Admins []string
AdminAdd bool
AdminAddPlaylists bool
AdminSkip bool
AdminHelp bool
AdminVolume bool
AdminMove bool
AdminReload bool
AdminReset bool
AdminNumSongs bool
AdminNextSong bool
AdminCurrentSong bool
AdminSetComment bool
AdminNumCached bool
AdminCacheSize bool
AdminKill bool
2015-10-09 21:49:56 +02:00
AdminShuffle bool
AdminShuffleToggle bool
}
2015-04-09 03:47:39 +02:00
}
2014-12-13 05:52:44 +01:00
2014-12-27 19:05:13 +01:00
// Loads mumbledj.gcfg into dj.conf, a variable of type DjConfig.
2014-12-16 01:41:15 +01:00
func loadConfiguration() error {
if gcfg.ReadFileInto(&dj.conf, fmt.Sprintf("%s/.mumbledj/config/mumbledj.gcfg", dj.homeDir)) == nil {
return nil
2014-12-16 01:41:15 +01:00
}
2015-05-10 07:00:24 +02:00
fmt.Printf("%s/.mumbledj/config/mumbledj.gcfg\n", dj.homeDir)
return errors.New("Configuration load failed.")
2014-12-13 05:52:44 +01:00
}