From 2bd7869b01e67031bc780e37323c339e4057ea21 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 5 Jul 2021 18:20:41 -0700 Subject: feat(munch): conditional sub-process spawning (worlds/ discord bot) --- config.example.yml | 3 +++ munch.go | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/config.example.yml b/config.example.yml index 907638f..07c4ded 100644 --- a/config.example.yml +++ b/config.example.yml @@ -1,4 +1,6 @@ worlds: + enable: false + server: # These shouldn't change ip: 209.240.84.122 port: 6650 @@ -9,5 +11,6 @@ worlds: avatar: Vamp.mov discord: + enable: false token: SoMetOKen22 prefix: m~ diff --git a/munch.go b/munch.go index aa4932f..da1a28e 100644 --- a/munch.go +++ b/munch.go @@ -7,6 +7,7 @@ import ( "github.com/Whirlsplash/munch/pkg/config" "github.com/Whirlsplash/munch/pkg/discord" "github.com/Whirlsplash/munch/pkg/server" + "github.com/spf13/viper" "sync" ) @@ -16,18 +17,22 @@ func main() { var wg sync.WaitGroup // Discord bot - wg.Add(1) - go func() { - discord.Do() - wg.Done() - }() - wg.Add(1) + if viper.GetBool("discord.enable") { + wg.Add(1) + go func() { + discord.Do() + wg.Done() + }() + } // Worlds bot - go func() { - server.Do() - wg.Done() - }() + if viper.GetBool("worlds.enable") { + wg.Add(1) + go func() { + server.Do() + wg.Done() + }() + } wg.Wait() } -- cgit v1.2.3