From 5170e96f7e1cd8fd0a8a0208cb47f7e103fbb939 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Wed, 12 Jan 2022 23:51:16 -0500 Subject: [PATCH] dont re-send help, mark all help as done if help has been sent, log noop for search --- config.json | 4 +--- main.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config.json b/config.json index aef5725..61672ad 100644 --- a/config.json +++ b/config.json @@ -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": { diff --git a/main.go b/main.go index e2a401e..d485fc9 100644 --- a/main.go +++ b/main.go @@ -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