Browse Source

Add reminder for running command

master
Gregory Rudolph 3 years ago
parent
commit
31a7402c82
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 4
      commands.go

4
commands.go

@ -88,6 +88,7 @@ func listVehicles(m chat1.MsgSummary) { @@ -88,6 +88,7 @@ func listVehicles(m chat1.MsgSummary) {
func deferTime(m chat1.MsgSummary) {
parts := strings.Split(m.Content.Text.Body, " ")
t := parts[1]
start := time.Now()
command := strings.Join(parts[2:], " ")
m.Content.Text.Body = fmt.Sprintf("!%+v", command)
timer, err := time.ParseDuration(t)
@ -97,8 +98,9 @@ func deferTime(m chat1.MsgSummary) { @@ -97,8 +98,9 @@ func deferTime(m chat1.MsgSummary) {
log.LogError("%+v: %+v", tracker, err)
return
}
k.SendMessageByConvID(m.ConvID, fmt.Sprintf("I will run %+v at %+v", command, time.Now().Add(timer).Format("Jan _2 15:04:05")))
k.SendMessageByConvID(m.ConvID, fmt.Sprintf("I will run `%+v` at %+v", command, time.Now().Add(timer).Format("Jan _2 15:04:05")))
time.Sleep(timer)
k.SendMessageByConvID(m.ConvID, fmt.Sprintf("Running `%+v` from %+v", command, start.Format("Jan _2 15:04:05")))
handleChat(m)
}

Loading…
Cancel
Save