Compare commits
4 Commits
427bec5081
...
41209f3ee3
Author | SHA1 | Date | |
---|---|---|---|
41209f3ee3 | |||
|
977136d9c2 | ||
|
b05c48cfbb | ||
|
11a792d96c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
data/config.toml
|
||||
data/options.json
|
@ -33,7 +33,7 @@ func CheckAnn() {
|
||||
} else {
|
||||
log.Println("Announcements disabled")
|
||||
http.HandleFunc("/api/announcements", func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, "Disabled")
|
||||
http.Error(w, "Announcements are disabled.", http.StatusNotFound)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
23
api/form.go
23
api/form.go
@ -1,9 +1,12 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/kataras/hcaptcha"
|
||||
|
||||
"fmt"
|
||||
@ -22,6 +25,26 @@ var (
|
||||
client = hcaptcha.New(secretKey) /* See `Client.FailureHandler` too. */
|
||||
)
|
||||
|
||||
func FormCheck() {
|
||||
jsonFile, err := os.Open("./data/options.json")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer jsonFile.Close()
|
||||
byteValue, _ := ioutil.ReadAll(jsonFile)
|
||||
var result map[string]interface{}
|
||||
json.Unmarshal([]byte(byteValue), &result)
|
||||
res := result["Form"]
|
||||
if res == "true" {
|
||||
Form()
|
||||
} else {
|
||||
log.Println("Forms disabled")
|
||||
http.HandleFunc("/api/form", func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, "Disabled")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Form() {
|
||||
http.HandleFunc("/api/form", client.HandlerFunc(theActualFormCode))
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ func AuthToken() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting segfautils.auth_token", err.Error())
|
||||
log.Println("Error reading config. Error getting: segfautils.auth_token", err.Error())
|
||||
}
|
||||
result := viper.GetString("segfautils.auth_token")
|
||||
return result
|
||||
|
@ -11,7 +11,7 @@ func HCaptchaSecretKey() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting hcaptcha.secret_key", err.Error())
|
||||
log.Println("Error reading config. Error getting: hcaptcha.secret_key", err.Error())
|
||||
}
|
||||
result := viper.GetString("hcaptcha.secret_key")
|
||||
return result
|
||||
|
@ -11,7 +11,7 @@ func HCaptchaSiteKey() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting hcaptcha.site_key", err.Error())
|
||||
log.Println("Error reading config. Error getting: hcaptcha.site_key", err.Error())
|
||||
}
|
||||
result := viper.GetString("hcaptcha.site_key")
|
||||
return result
|
||||
|
@ -11,7 +11,7 @@ func OptForm() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting options.form", err.Error())
|
||||
log.Println("Error reading config. Error getting: options.form", err.Error())
|
||||
}
|
||||
result := viper.GetString("options.form")
|
||||
return result
|
||||
|
@ -11,7 +11,7 @@ func OptAnn() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting options.announce", err.Error())
|
||||
log.Println("Error reading config. Error getting: options.announce", err.Error())
|
||||
}
|
||||
result := viper.GetString("options.announce")
|
||||
return result
|
||||
|
@ -12,7 +12,7 @@ func Port() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting segfautils.port", err.Error())
|
||||
log.Println("Error reading config. Error getting: segfautils.port", err.Error())
|
||||
}
|
||||
result := strconv.Itoa(viper.GetInt("segfautils.port"))
|
||||
return result
|
||||
|
@ -11,7 +11,7 @@ func WebhookURL() string {
|
||||
viper.AddConfigPath("./data")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println("Error reading config for getting segfautils.webhook_url", err.Error())
|
||||
log.Println("Error reading config. Error getting: segfautils.webhook_url", err.Error())
|
||||
}
|
||||
result := viper.GetString("segfautils.webhook_url")
|
||||
return result
|
||||
|
@ -1 +0,0 @@
|
||||
{"Announcements":"false","Form":"true"}
|
Reference in New Issue
Block a user