multi-client but one ntg search, nontrivial config.json change

This commit is contained in:
Bel LaPointe
2022-01-11 22:54:18 -05:00
parent 5a4bcecac7
commit e546034c26
8 changed files with 138 additions and 54 deletions

View File

@@ -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 {