multi-client but one ntg search, nontrivial config.json change
This commit is contained in:
@@ -9,19 +9,21 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Name string
|
||||
Interval struct {
|
||||
Input Duration
|
||||
OK Duration
|
||||
Error Duration
|
||||
}
|
||||
States []State
|
||||
Clients map[string]struct {
|
||||
States []State
|
||||
IDs struct {
|
||||
Matrix string
|
||||
}
|
||||
}
|
||||
Storage []string
|
||||
Client string
|
||||
Message struct {
|
||||
Matrix struct {
|
||||
ReceiveEnabled bool
|
||||
Client string
|
||||
Mock bool
|
||||
Homeserver string
|
||||
Username string
|
||||
@@ -54,6 +56,21 @@ func configPath() string {
|
||||
return p
|
||||
}
|
||||
|
||||
func AllStates() []State {
|
||||
c := Get()
|
||||
statem := map[State]struct{}{}
|
||||
for _, v := range c.Clients {
|
||||
for _, state := range v.States {
|
||||
statem[state] = struct{}{}
|
||||
}
|
||||
}
|
||||
states := make([]State, 0, len(statem)+1)
|
||||
for k := range statem {
|
||||
states = append(states, k)
|
||||
}
|
||||
return states
|
||||
}
|
||||
|
||||
func Refresh() error {
|
||||
b, err := ioutil.ReadFile(configPath())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user