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
|
|
|
|
2016-01-27 05:52:00 +01:00
|
|
|
"github.com/scalingdata/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.
|
2014-12-15 05:35:44 +01:00
|
|
|
type DjConfig struct {
|
|
|
|
General struct {
|
2015-12-14 04:34:33 +01:00
|
|
|
CommandPrefix string
|
|
|
|
SkipRatio float32
|
|
|
|
PlaylistSkipRatio float32
|
|
|
|
DefaultComment string
|
|
|
|
MaxSongDuration int
|
|
|
|
MaxSongPerPlaylist int
|
|
|
|
AutomaticShuffleOn bool
|
2015-12-20 06:21:11 +01:00
|
|
|
AnnounceNewTrack bool
|
2016-01-12 04:27:29 +01:00
|
|
|
PlayerCommand string
|
2014-12-15 05:35:44 +01:00
|
|
|
}
|
2015-02-18 00:43:20 +01:00
|
|
|
Cache struct {
|
|
|
|
Enabled bool
|
|
|
|
MaximumSize int64
|
|
|
|
ExpireTime float64
|
|
|
|
}
|
2014-12-15 05:35:44 +01:00
|
|
|
Volume struct {
|
|
|
|
DefaultVolume float32
|
2014-12-16 01:41:15 +01:00
|
|
|
LowestVolume float32
|
2014-12-15 05:35:44 +01:00
|
|
|
HighestVolume float32
|
|
|
|
}
|
|
|
|
Aliases struct {
|
2015-01-03 20:31:29 +01:00
|
|
|
AddAlias string
|
2015-12-15 02:07:12 +01:00
|
|
|
AddNextAlias string
|
2015-01-03 20:31:29 +01:00
|
|
|
SkipAlias string
|
|
|
|
SkipPlaylistAlias string
|
|
|
|
AdminSkipAlias string
|
|
|
|
AdminSkipPlaylistAlias string
|
2015-01-11 00:15:12 +01:00
|
|
|
HelpAlias string
|
2015-01-03 20:31:29 +01:00
|
|
|
VolumeAlias string
|
|
|
|
MoveAlias string
|
2016-06-17 18:15:11 +02:00
|
|
|
JoinMeAlias string
|
2015-01-03 20:31:29 +01:00
|
|
|
ReloadAlias string
|
2015-01-06 04:16:59 +01:00
|
|
|
ResetAlias string
|
2015-01-10 22:03:52 +01:00
|
|
|
NumSongsAlias string
|
2015-01-13 01:21:53 +01:00
|
|
|
NextSongAlias string
|
2015-01-25 20:27:28 +01:00
|
|
|
CurrentSongAlias string
|
2015-02-10 00:08:09 +01:00
|
|
|
SetCommentAlias string
|
2015-02-18 00:43:20 +01:00
|
|
|
NumCachedAlias string
|
|
|
|
CacheSizeAlias string
|
2015-01-03 20:31:29 +01:00
|
|
|
KillAlias string
|
2015-10-09 21:49:56 +02:00
|
|
|
ShuffleAlias string
|
2015-10-07 23:58:54 +02:00
|
|
|
ShuffleOnAlias string
|
|
|
|
ShuffleOffAlias string
|
2015-12-14 04:34:33 +01:00
|
|
|
ListSongsAlias string
|
2016-02-02 13:07:36 +01:00
|
|
|
VersionAlias string
|
2014-12-15 05:35:44 +01:00
|
|
|
}
|
|
|
|
Permissions struct {
|
2015-12-14 04:34:33 +01:00
|
|
|
AdminsEnabled bool
|
|
|
|
Admins []string
|
|
|
|
AdminAdd bool
|
2015-12-15 02:07:12 +01:00
|
|
|
AdminAddNext bool
|
2015-12-14 04:34:33 +01:00
|
|
|
AdminAddPlaylists bool
|
|
|
|
AdminSkip bool
|
|
|
|
AdminHelp bool
|
|
|
|
AdminVolume bool
|
|
|
|
AdminMove bool
|
2016-06-17 18:15:11 +02:00
|
|
|
AdminJoinMe bool
|
2015-12-14 04:34:33 +01:00
|
|
|
AdminReload bool
|
|
|
|
AdminReset bool
|
|
|
|
AdminNumSongs bool
|
|
|
|
AdminNextSong bool
|
|
|
|
AdminCurrentSong bool
|
|
|
|
AdminSetComment bool
|
|
|
|
AdminNumCached bool
|
|
|
|
AdminCacheSize bool
|
|
|
|
AdminKill bool
|
|
|
|
AdminShuffle bool
|
|
|
|
AdminShuffleToggle bool
|
|
|
|
AdminListSongs bool
|
2016-02-02 13:07:36 +01:00
|
|
|
AdminVersion bool
|
2014-12-15 05:35:44 +01:00
|
|
|
}
|
2015-11-19 08:05:23 +01:00
|
|
|
ServiceKeys struct {
|
2015-12-14 04:34:33 +01:00
|
|
|
Youtube string
|
|
|
|
SoundCloud string
|
2015-11-19 08:05:23 +01:00
|
|
|
}
|
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 {
|
2014-12-27 09:25:49 +01:00
|
|
|
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
|
|
|
}
|