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

This commit is contained in:
Bel LaPointe
2022-01-12 23:51:16 -05:00
parent 826278fa78
commit 5170e96f7e
2 changed files with 9 additions and 6 deletions

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