-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.go
55 lines (49 loc) · 1.7 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
54
55
package tfcc
import (
"github.com/spf13/viper"
"os"
"path/filepath"
)
var (
tfccConfig = viper.New()
bilibiliData = viper.New()
permData = viper.New()
)
func initConfig() {
if err := os.MkdirAll(filepath.Join("config", "org.tfcc.bot"), 0755); err != nil {
panic(err)
}
if err := os.MkdirAll(filepath.Join("data", "org.tfcc.bot"), 0755); err != nil {
panic(err)
}
tfccConfig.AddConfigPath(filepath.Join("config", "org.tfcc.bot"))
tfccConfig.SetConfigName("TFCCConfig")
tfccConfig.SetConfigType("yml")
tfccConfig.SetDefault("bilibili.area_v2", 236)
tfccConfig.SetDefault("bilibili.mid", 12345678)
tfccConfig.SetDefault("bilibili.room_id", 12345678)
tfccConfig.SetDefault("qq.super_admin_qq", int64(12345678))
tfccConfig.SetDefault("qq.qq_group", []int64{12345678})
_ = tfccConfig.SafeWriteConfigAs(filepath.Join("config", "org.tfcc.bot", "TFCCConfig.yml"))
if err := tfccConfig.ReadInConfig(); err != nil {
panic(err)
}
bilibiliData.AddConfigPath(filepath.Join("data", "org.tfcc.bot"))
bilibiliData.SetConfigName("BilibiliData")
bilibiliData.SetConfigType("yml")
bilibiliData.SetDefault("cookies", []string(nil))
bilibiliData.SetDefault("live", int64(0))
_ = bilibiliData.SafeWriteConfigAs(filepath.Join("data", "org.tfcc.bot", "BilibiliData.yml"))
if err := bilibiliData.ReadInConfig(); err != nil {
panic(err)
}
permData.AddConfigPath(filepath.Join("data", "org.tfcc.bot"))
permData.SetConfigName("PermData")
permData.SetConfigType("yml")
permData.SetDefault("admin", []int64(nil))
permData.SetDefault("white_list", []int64(nil))
_ = permData.SafeWriteConfigAs(filepath.Join("data", "org.tfcc.bot", "PermData.yml"))
if err := permData.ReadInConfig(); err != nil {
panic(err)
}
}