Add PerformStartupChecks() to check for YOUTUBE_API_KEY and other stuff in the future
This commit is contained in:
parent
f7e8cf1e40
commit
bf5ec20416
11
main.go
11
main.go
|
@ -133,6 +133,15 @@ func (dj *mumbledj) SendPrivateMessage(user *gumble.User, message string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PerformStartupChecks checks the MumbleDJ installation to ensure proper usage.
|
||||||
|
func PerformStartupChecks() {
|
||||||
|
if os.Getenv("YOUTUBE_API_KEY") == "" {
|
||||||
|
fmt.Printf("You do not have a YouTube API key defined in your environment variables.\n" +
|
||||||
|
"Please see the following link for info on how to fix this: https://github.com/matthieugrieger/mumbledj#youtube-api-keys\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// dj variable declaration. This is done outside of main() to allow global use.
|
// dj variable declaration. This is done outside of main() to allow global use.
|
||||||
var dj = mumbledj{
|
var dj = mumbledj{
|
||||||
keepAlive: make(chan bool),
|
keepAlive: make(chan bool),
|
||||||
|
@ -145,6 +154,8 @@ var dj = mumbledj{
|
||||||
// args, sets up the gumble client and its listeners, and then connects to the server.
|
// args, sets up the gumble client and its listeners, and then connects to the server.
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
PerformStartupChecks()
|
||||||
|
|
||||||
if currentUser, err := user.Current(); err == nil {
|
if currentUser, err := user.Current(); err == nil {
|
||||||
dj.homeDir = currentUser.HomeDir
|
dj.homeDir = currentUser.HomeDir
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue