-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
53 lines (43 loc) · 1.14 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
52
53
package main
import (
"fmt"
"os"
"gopkg.in/yaml.v2"
)
type Config struct {
Path string `yaml:"path"`
Country string `yaml:"country"`
XL bool `yaml:"xl"`
DeleteOldVersion bool `yaml:"delete_old_version"`
}
const configFileName = "config.yml"
func loadConfig() Config {
config := Config{
Path: "",
Country: "us",
XL: true,
DeleteOldVersion: true,
}
data, err := os.ReadFile(configFileName)
if err != nil {
fmt.Println("Config file not found or unreadable, using default values.")
return config
}
err = yaml.Unmarshal(data, &config)
if err != nil {
fmt.Println("Error parsing config file, using default values.")
return config
}
validCountries := map[string]bool{"us": true, "es": true, "d": true, "br": true}
if _, ok := validCountries[config.Country]; !ok {
fmt.Println("Invalid country in config, defaulting to 'us'.")
config.Country = "us"
}
return config
}
func getHabboExe(config Config) string {
if config.XL {
return fmt.Sprintf("HabboHotel-o%s-xl.exe", config.Country)
}
return fmt.Sprintf("HabboHotel-o%s.exe", config.Country)
}