Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6569631928 | ||
|
|
e963162303 | ||
|
|
ac9ccf633a | ||
|
|
b4007a8eb5 | ||
|
|
358eb0a724 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Name": "pa",
|
"Name": "pa",
|
||||||
"Interval": {
|
"Interval": {
|
||||||
"Email": "15m0s..15m0s",
|
"Email": "10s..30s",
|
||||||
"OK": "6h0m0s..6h0m0s",
|
"OK": "6h0m0s..6h0m0s",
|
||||||
"Error": "6h0m0s..6h0m0s"
|
"Error": "6h0m0s..6h0m0s"
|
||||||
},
|
},
|
||||||
|
|||||||
51
main.go
51
main.go
@@ -11,6 +11,7 @@ import (
|
|||||||
"local/truckstop/message"
|
"local/truckstop/message"
|
||||||
"log"
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -66,19 +67,33 @@ func matrixrecv() error {
|
|||||||
states[state] = struct{}{}
|
states[state] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(states) == 0 {
|
setNewStates(states)
|
||||||
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)
|
|
||||||
return nil
|
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)
|
||||||
|
if err := sendNewStates(conf.States); err != nil {
|
||||||
|
log.Printf("failed to send new states %+v: %v", conf.States, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func email() error {
|
func email() error {
|
||||||
log.Printf("checking email...")
|
log.Printf("checking email...")
|
||||||
ch, err := config.Get().Emailer.ReadIMAP()
|
ch, err := config.Get().Emailer.ReadIMAP()
|
||||||
@@ -101,16 +116,7 @@ func email() error {
|
|||||||
states[state] = struct{}{}
|
states[state] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(states) == 0 {
|
setNewStates(states)
|
||||||
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)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,3 +234,8 @@ func sendJob(job broker.Job) error {
|
|||||||
sender := message.NewMatrix()
|
sender := message.NewMatrix()
|
||||||
return sender.Send(job.FormatMultilineText())
|
return sender.Send(job.FormatMultilineText())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendNewStates(states []config.State) error {
|
||||||
|
sender := message.NewMatrix()
|
||||||
|
return sender.Send(fmt.Sprintf("now searching for loads from: %+v", states))
|
||||||
|
}
|
||||||
|
|||||||
11
todo.yaml
11
todo.yaml
@@ -1,4 +1,15 @@
|
|||||||
todo:
|
todo:
|
||||||
|
- send matrix msg on config change
|
||||||
|
- rm email
|
||||||
|
- 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
|
- todo: filter out jobs like CA
|
||||||
subtasks:
|
subtasks:
|
||||||
- banlist criteria like vendors, brokers, metadata
|
- banlist criteria like vendors, brokers, metadata
|
||||||
|
|||||||
Reference in New Issue
Block a user