dont re-send help, mark all help as done if help has been sent, log noop for search

master v0.0.9
Bel LaPointe 2022-01-12 23:51:16 -05:00
parent 826278fa78
commit 5170e96f7e
2 changed files with 9 additions and 6 deletions

View File

@ -17,13 +17,12 @@
},
"Maps": {
"URIFormat": "https://maps.googleapis.com/maps/api/staticmap?center=%s\u0026markers=label=A|%s\u0026zoom=5\u0026size=250x250\u0026scale=1\u0026format=jpeg\u0026maptype=roadmap\u0026key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg",
"Pickup": false,
"Pickup": true,
"Dropoff": false
},
"Clients": {
"bel": {
"States": [
"GA",
"NC"
],
"IDs": {
@ -52,7 +51,6 @@
},
"pa": {
"States": [
"GA",
"NC"
],
"IDs": {

11
main.go
View File

@ -63,12 +63,12 @@ func matrixrecv() error {
if !strings.HasPrefix(msg.Content, "!help") {
continue
}
key := fmt.Sprintf("help_%d", msg.Timestamp.Unix())
db := config.Get().DB()
if !printed {
key := fmt.Sprintf("help_%d", msg.Timestamp.Unix())
db := config.Get().DB()
if _, err := db.Get(key); err == storage.ErrNotFound {
log.Printf("sending help")
help := fmt.Sprintf("commands:\n\t!help\tprint this help\n\t!state nc NC nC Nc\tset states for self\n\t!available 2022-12-31\tset date self is available for work\n\nrun a command for someone else: `!state ga @caleb`")
help := fmt.Sprintf("commands:\n...`!help`...print this help\n...`!state nc NC nC Nc`...set states for self\n...`!available 2022-12-31`...set date self is available for work\n\nrun a command for someone else: `!state ga @caleb`")
if err := sender.Send(help); err != nil {
log.Printf("failed to send help: %v", err)
} else {
@ -78,6 +78,10 @@ func matrixrecv() error {
}
}
}
} else {
if err := db.Set(key, []byte{'k'}); err != nil {
log.Printf("failed to mark help given @%s: %v", key, err)
}
}
}
}()
@ -166,6 +170,7 @@ func setNewStates(states map[string]map[config.State]struct{}) {
})
clientconf := conf.Clients[client]
if fmt.Sprint(newstates) == fmt.Sprint(clientconf.States) {
message.NewMatrix().Send(fmt.Sprintf("%s: still searching for %+v", client, newstates))
continue
}
clientconf.States = newstates