diff --git a/cspp/README.md b/cspp/README.md index c73852e..271e94f 100644 --- a/cspp/README.md +++ b/cspp/README.md @@ -10,9 +10,10 @@ Have you been making stupid/silly/wonderful AI pictures and art work? Do you wan You need to set the following enviornment variables. - SLACK_TOKEN - IMAGE_DIRECTORY - SLACK_CHANNEL + CSPP_SLACK_TOKEN + CSPP_DATA_DIRECTORY + CSPP_SLACK_CHANNEL + CSPP_SLACK_TEAM # License MIT diff --git a/cspp/api_key.go b/cspp/api_key.go index 6b95b81..39ffc2e 100644 --- a/cspp/api_key.go +++ b/cspp/api_key.go @@ -197,7 +197,7 @@ func generateApiKey() string { } func validateSlackId(userID, teamID string) bool { - token := viper.GetString("SLACK_TOKEN") + token := viper.GetString("slack_token") log.Debugln("(validateSlackId) userId: ", userID, " teamId: ", teamID, " token: ", token) api := slack.New(token) userInfo, err := api.GetUserInfo(userID) diff --git a/cspp/main.go b/cspp/main.go index e4c1fa3..f1a7af6 100644 --- a/cspp/main.go +++ b/cspp/main.go @@ -24,40 +24,40 @@ func init() { viper.SetDefault("port", "8080") viper.SetDefault("data_dir", "data") - viper.BindEnv("port", "PORT") - viper.BindEnv("data_dir", "DATA_DIR") + viper.BindEnv("port", "CSPP_PORT") + viper.BindEnv("data_dir", "CSPP_DATA_DIR") var bugout bool - if value := os.Getenv("SLACK_TOKEN"); value == "" { - fmt.Println("SLACK_TOKEN environment variable not set.") + if value := os.Getenv("CSPP_SLACK_TOKEN"); value == "" { + fmt.Println("CSPP_SLACK_TOKEN environment variable not set.") bugout = true } - if value := os.Getenv("SLACK_CHANNEL"); value == "" { - fmt.Println("SLACK_CHANNEL environment variable not set.") + if value := os.Getenv("CSPP_SLACK_CHANNEL"); value == "" { + fmt.Println("CSPP_SLACK_CHANNEL environment variable not set.") bugout = true } - if value := os.Getenv("SLACK_TEAM_ID"); value == "" { - fmt.Println("SLACK_TEAM_ID environment variable not set.") + if value := os.Getenv("CSPP_SLACK_TEAM_ID"); value == "" { + fmt.Println("CSPP_SLACK_TEAM_ID environment variable not set.") bugout = true } if bugout == true { os.Exit(1) } - viper.MustBindEnv("slack_token", "SLACK_TOKEN") - viper.MustBindEnv("slack_channel", "SLACK_CHANNEL") - viper.MustBindEnv("slack_team_id", "SLACK_TEAM_ID") + viper.MustBindEnv("slack_token", "CSPP_SLACK_TOKEN") + viper.MustBindEnv("slack_channel", "CSPP_SLACK_CHANNEL") + viper.MustBindEnv("slack_team_id", "CSPP_SLACK_TEAM_ID") viper.SetDefault("discard_dir", viper.GetString("data_dir")+"/discard") viper.SetDefault("processed_dir", viper.GetString("data_dir")+"/processed") viper.SetDefault("uploads_dir", viper.GetString("data_dir")+"/uploads") viper.SetDefault("credentials_dir", viper.GetString("data_dir")+"/credentials") - viper.BindEnv("data_dir", "DATA_DIR") - viper.BindEnv("discard_dir", "DISCARD_DIR") - viper.BindEnv("processed_dir", "PROCESSED_DIR") - viper.BindEnv("uploads_dir", "UPLOADS_DIR") - viper.BindEnv("credentials_dir", "CREDENTIALS_DIR") + viper.BindEnv("data_dir", "CSPP_DATA_DIR") + viper.BindEnv("discard_dir", "CSPP_DISCARD_DIR") + viper.BindEnv("processed_dir", "CSPP_PROCESSED_DIR") + viper.BindEnv("uploads_dir", "CSPP_UPLOADS_DIR") + viper.BindEnv("credentials_dir", "CSPP_CREDENTIALS_DIR") setupDirectory(viper.GetString("data_dir")) setupDirectory(viper.GetString("discard_dir")) diff --git a/cspp/slack_sender.go b/cspp/slack_sender.go index beac48c..7d8044f 100644 --- a/cspp/slack_sender.go +++ b/cspp/slack_sender.go @@ -128,7 +128,7 @@ func getAuthor(apiKey string) string { if err != nil { log.Errorln("Unable to load api entry from file: ", apiKey, " error: ", err) } - token := viper.GetString("SLACK_TOKEN") + token := viper.GetString("slack_token") slackApi := slack.New(token) userInfo, err := slackApi.GetUserInfo(ae.SlackId) if err != nil {