-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
58 lines (51 loc) · 1021 Bytes
/
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
56
57
58
package mud
import (
"io/ioutil"
"time"
"gopkg.in/yaml.v2"
)
type Config struct {
Address string
Login struct {
Name string
Password string
}
Prompt Pattern
Abilities map[string]struct {
Ready []string
Wait []string
}
Triggers map[Pattern]string
Vars map[string]string
Lists map[string][]string
Aliases map[string]string
Log map[string]struct {
Timestamp bool `yaml:"timestamp,omitempty"`
Match map[Pattern]string `yaml:"match,omitempty"`
} `yaml:"log,omitempty"`
Dump map[string]*DumpConfig
Highlight map[Pattern]*Color
Replace map[Pattern]struct {
With string
Color *Color
}
Gag []Pattern
Timers []struct {
Every time.Duration
Do string
}
}
type DumpConfig struct {
Cmd string
Dest string
Match map[Pattern]string
}
func UnmarshalConfig(path string) (Config, error) {
var cfg Config
buf, err := ioutil.ReadFile(path)
if err != nil {
return cfg, err
}
err = yaml.Unmarshal(buf, &cfg)
return cfg, err
}