Added execute single online presence status message

This commit is contained in:
2021-09-27 19:23:30 +02:00
parent 7765cb32a9
commit f72b8c0da1
5 changed files with 73 additions and 23 deletions

View File

@@ -17,7 +17,7 @@ func Load() {
GeneralOptions: GeneralOptions{
PresenceStatusDelay: int64(getEnvInt("PRESENCE_STATUS_DELAY", 2) * 60),
CommandReplyDelay: getEnvInt("COMMAND_REPLY_DELAY", 10),
ExecuteSingleStatusMessage: getEnvBool("EXECUTE_SIGLE_STATUS_MESSAGE"),
ExecuteSingleStatusMessage: getEnvBool("EXECUTE_SNIGLE_STATUS_MESSAGE"),
},
}
}

View File

@@ -34,7 +34,7 @@ func getEnvInt(key string, defaultValue int) int {
}
// getEnv extracts the bool value from environment variable
func getEnvBool(env string) bool {
func mustGetEnvBool(env string) bool {
envVal := mustGetEnv(env)
value, err := strconv.ParseBool(envVal)
@@ -45,6 +45,18 @@ func getEnvBool(env string) bool {
return value
}
// getEnv extracts the bool value from environment variable
func getEnvBool(env string) bool {
envVal := getEnv(env, "false")
value, err := strconv.ParseBool(envVal)
if err != nil {
value = false
}
return value
}
// mustGetEnv returns value for give key from environment
// if key is not present in environment function will panic
func mustGetEnv(key string) string {