Compare commits

...

3 Commits

Author SHA1 Message Date
Bel LaPointe
ac9ccf633a Setnewstates as method, sort, check and set to skip noop 2022-01-11 17:04:16 -05:00
Bel LaPointe
b4007a8eb5 todo 2022-01-11 16:59:41 -05:00
Bel LaPointe
358eb0a724 change interval email 2022-01-11 09:47:21 -05:00
3 changed files with 33 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
{
"Name": "pa",
"Interval": {
"Email": "15m0s..15m0s",
"Email": "10s..30s",
"OK": "6h0m0s..6h0m0s",
"Error": "6h0m0s..6h0m0s"
},

43
main.go
View File

@@ -11,6 +11,7 @@ import (
"local/truckstop/message"
"log"
"regexp"
"sort"
"strings"
"sync"
"time"
@@ -66,19 +67,30 @@ func matrixrecv() error {
states[state] = struct{}{}
}
}
if len(states) == 0 {
return nil
}
conf := *config.Get()
conf.States = []config.State{}
for k := range states {
conf.States = append(conf.States, k)
}
log.Printf("%+v, %+v", states, conf)
config.Set(conf)
setNewStates(states)
return nil
}
func setNewStates(states map[config.State]struct{}) {
if len(states) == 0 {
return
}
newstates := []config.State{}
for k := range states {
newstates = append(newstates, k)
}
sort.Slice(newstates, func(i, j int) bool {
return newstates[i] < newstates[j]
})
conf := *config.Get()
if fmt.Sprint(newstates) == fmt.Sprint(conf.States) {
return
}
conf.States = newstates
log.Printf("updating config new states: %+v", conf)
config.Set(conf)
}
func email() error {
log.Printf("checking email...")
ch, err := config.Get().Emailer.ReadIMAP()
@@ -101,16 +113,7 @@ func email() error {
states[state] = struct{}{}
}
}
if len(states) == 0 {
return nil
}
conf := *config.Get()
conf.States = []config.State{}
for k := range states {
conf.States = append(conf.States, k)
}
log.Printf("%+v, %+v", states, conf)
config.Set(conf)
setNewStates(states)
return nil
}

View File

@@ -1,4 +1,13 @@
todo:
- modify old items once no longer available
- many users -> 1 ntg query
- accept after date
- "caleb: my-usual-stuff" to alias
- rate LIMIT
- more than NTG
- accept pause commands
- rate limit brokers
- write to matrix on config change like states
- todo: filter out jobs like CA
subtasks:
- banlist criteria like vendors, brokers, metadata