b09967f9e6
Pure move: actionFact, actionReminder, actionAct and actionNote each get their own actions_<intent>.go. The two small ones (chat, system) and the actionHandlers table stay in actions.go, which is now just the dispatch layer and the notes about what does not belong in it. No behaviour change — only the file a handler is read in.
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/kami/maven/internal/router"
|
|
)
|
|
|
|
// actionReminder handles router.IntentReminder: parse the time when stage-0
|
|
// skipped the extractor, then create the reminder.
|
|
func (h *reactiveHandler) actionReminder(ctx context.Context, dec router.Decision) string {
|
|
if !dec.Slots.HasTime {
|
|
// Stage-0 (reminder-wakeword grammar) skips the extractor, so the
|
|
// time wasn't parsed. Run the parser as a fallback.
|
|
if dec.Stage == 0 && h.timeParser != nil {
|
|
t, ok, err := h.timeParser.Parse(ctx, dec.Utterance, h.now())
|
|
if err == nil && ok {
|
|
dec.Slots.Time = t
|
|
dec.Slots.HasTime = true
|
|
}
|
|
}
|
|
if !dec.Slots.HasTime {
|
|
return "не получилось разобрать время напоминания."
|
|
}
|
|
}
|
|
payload := `{"text":` + jsonString(dec.Utterance) + `}`
|
|
if _, err := h.api.CreateReminder(ctx, dec.Slots.Time, payload, ""); err != nil {
|
|
log.Printf("voice: create reminder: %v", err)
|
|
return "не получилось поставить напоминание."
|
|
}
|
|
return ""
|
|
}
|