-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
51 lines (44 loc) · 1.09 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"log"
"os"
"gopkg.in/yaml.v2"
)
var config Config
// Config exposes config.yaml
type Config struct {
HCaptchaURLs []string `yaml:"hCaptchaURLs"`
Users []User `yaml:"users"`
Username string `yaml:"username"`
Password string `yaml:"password"`
OTPSecret string `yaml:"OTPSecret"`
TelegramID string `yaml:"telegramID"`
ImgurClientID string `yaml:"imgurClientID"`
ImgurSecret string `yaml:"imgurSecret"`
ImgurRefreshToken string `yaml:"imgurRefreshToken"`
}
type User struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
OTPSecret string `yaml:"OTPSecret"`
TelegramID string `yaml:"telegramID"`
}
func handleErrorFatal(err error) {
if err != nil {
log.Fatal(err)
}
}
func readConfig() Config {
configFile := "./config.yaml"
f, err := os.Open(configFile)
if err != nil {
log.Fatal("Could not open config file.")
}
dec := yaml.NewDecoder(f)
var config Config
err = dec.Decode(&config)
if err != nil {
log.Fatal("Could not open config file.")
}
return config
}