2022-07-27 22:30:48 +05:30
// Please ignore my terrible code :) It works
2022-08-04 01:07:12 +05:30
package utils
2022-07-23 01:04:09 +05:30
import (
"log"
2022-08-02 14:11:17 +05:30
"os"
2022-07-23 01:04:09 +05:30
)
2022-07-27 22:30:48 +05:30
var (
unused string
2022-08-02 14:11:17 +05:30
ok1 bool
2022-07-27 22:30:48 +05:30
)
2022-07-23 01:04:09 +05:30
func CheckEnv ( ) {
2022-08-02 14:11:17 +05:30
unused , ok1 = os . LookupEnv ( "SEGFAUTILS_PORT" )
2022-07-23 01:04:09 +05:30
if ok1 {
2022-08-02 14:11:17 +05:30
log . Println ( "[Segfautils] Environment variable SEGFAUTILS_PORT is set as " + unused )
2022-07-23 01:04:09 +05:30
} else {
2022-08-02 14:11:17 +05:30
log . Fatal ( "[Segfautils] Environment variable SEGFAUTILS_PORT is not set! Please set it to a number, for example 6893" )
2022-07-23 01:04:09 +05:30
}
2022-07-27 22:30:48 +05:30
unused , ok1 = os . LookupEnv ( "HCAPTCHA_SITE_KEY" )
2022-08-01 02:19:08 +05:30
if ! ok1 || unused == "YOURSITEKEY" {
2022-08-04 01:07:12 +05:30
log . Println ( "[Segfautils] Environment variable HCAPTCHA_SITE_KEY is not not set. It isn't required to be set, but without it, the example form will not work." )
2022-07-27 22:30:48 +05:30
} else {
2022-08-02 14:11:17 +05:30
log . Println ( "[Segfautils] Environment variable HCAPTCHA_SITE_KEY is set as " + unused )
2022-07-27 22:30:48 +05:30
}
unused , ok1 = os . LookupEnv ( "HCAPTCHA_SECRET_KEY" )
2022-08-01 02:19:08 +05:30
if ! ok1 || unused == "YOURSECRETKEY" {
2022-08-02 14:11:17 +05:30
log . Fatal ( "[Segfautils] Environment variable HCAPTCHA_SECRET_KEY is not set! Please set it to the secret key you got from hCaptcha." )
2022-07-27 22:30:48 +05:30
} else {
2022-08-02 14:11:17 +05:30
log . Println ( "[Segfautils] Environment variable HCAPTCHA_SECRET_KEY is set!" )
2022-07-27 22:30:48 +05:30
}
2022-08-02 14:11:17 +05:30
unused , ok1 = os . LookupEnv ( "SEGFAUTILS_WEBHOOK_URL" )
2022-08-01 02:19:08 +05:30
if ! ok1 || unused == "YOURWEBHOOKURL" {
2022-08-02 14:11:17 +05:30
log . Fatal ( "[Segfautils] Environment variable SEGFAUTILS_WEBHOOK_URL is not set! Please set it to your webhook URL. If that URL doesn't work, make an issue on GitHub!" )
2022-07-27 23:37:18 +05:30
} else {
2022-08-02 14:11:17 +05:30
log . Println ( "[Segfautils] Environment variable SEGFAUTILS_WEBHOOK_URL is set!" )
2022-07-27 23:37:18 +05:30
}
2022-08-04 01:07:12 +05:30
unused , ok1 = os . LookupEnv ( "SEGFAUTILS_AUTHTOKEN" )
if ! ok1 || unused == "YOURAUTHTOKEN" {
log . Fatal ( "[Segfautils] Environment variable SEGFAUTILS_AUTHTOKEN is not set! Please set it to a token you'd like to use for authorizing actions like announcements." )
} else {
log . Println ( "[Segfautils] Environment variable SEGFAUTILS_AUTHTOKEN is set!" )
}
2022-08-02 14:11:17 +05:30
log . Println ( "[Segfautils] ✅ Passed the Environment Variables check" )
}