-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
47 lines (39 loc) · 1.12 KB
/
config.go
File metadata and controls
47 lines (39 loc) · 1.12 KB
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
package main
import (
"log"
"os"
"github.com/goccy/go-yaml"
"github.com/google/uuid"
)
type ConfigStruct struct {
Token string `json:"token"`
UUIDSpace uuid.UUID `json:"uuid_space"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
Redirects map[string]string `json:"redirects"`
Maps map[string]MapStruct
Tags map[string][]string
}
type MapStruct struct {
MapUrl string `json:"mapUrl,omitempty"`
WamUrl string `json:"wamUrl,omitempty"`
Group string `json:"group"`
RoomName string `json:"roomName"`
EditorTags []string `json:"-" yaml:"editor_tags"`
AllowedTags []string `json:"-" yaml:"allowed_tags"`
}
var Config ConfigStruct
var GroupMap = make(map[string][]string)
func LoadConfig() {
f, err := os.Open("config.yaml")
if err != nil {
log.Panic("Failed to open config.yaml: ", err)
}
defer f.Close()
dec := yaml.NewDecoder(f)
if err := dec.Decode(&Config); err != nil {
log.Panic("Failed to decode config: ", err)
}
for k, m := range Config.Maps {
GroupMap[m.Group] = append(GroupMap[m.Group], k)
}
}