Add message when deferring command for later

This commit is contained in:
2021-07-06 11:11:55 -04:00
parent e7675db469
commit d08e5025fc

View File

@ -88,7 +88,8 @@ func listVehicles(m chat1.MsgSummary) {
func deferTime(m chat1.MsgSummary) { func deferTime(m chat1.MsgSummary) {
parts := strings.Split(m.Content.Text.Body, " ") parts := strings.Split(m.Content.Text.Body, " ")
t := parts[1] t := parts[1]
m.Content.Text.Body = fmt.Sprintf("!%+v", strings.Join(parts[1:], " ")) command := strings.Join(parts[1:], " ")
m.Content.Text.Body = fmt.Sprintf("!%+v", command)
timer, err := time.ParseDuration(t) timer, err := time.ParseDuration(t)
if err != nil { if err != nil {
tracker := uuid.NewString() tracker := uuid.NewString()
@ -96,6 +97,7 @@ func deferTime(m chat1.MsgSummary) {
log.LogError("%+v: %+v", tracker, err) log.LogError("%+v: %+v", tracker, err)
return return
} }
k.SendMessageByConvID(m.ConvID, fmt.Sprintf("I will run %+v at %+v", command, time.Now().Add(timer)))
time.Sleep(timer) time.Sleep(timer)
handleChat(m) handleChat(m)
} }