107 lines
3.9 KiB
Go
107 lines
3.9 KiB
Go
package hooks
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/d1nch8g/jules/engine/actions"
|
|
"github.com/d1nch8g/jules/engine/timeconv"
|
|
"github.com/d1nch8g/jules/engine/user"
|
|
)
|
|
|
|
const (
|
|
stage1 = `SYSTEM: STAGE 1 TRIGGER. Ask user to compliment someone they care about. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set a weekly reminder.`
|
|
stage2 = `SYSTEM: STAGE 2 TRIGGER. Ask if user drinks enough water. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set a daily hydration reminder.`
|
|
stage3 = `SYSTEM: STAGE 3 TRIGGER. Ask if user stretches regularly. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set a daily stretch reminder.`
|
|
stage4 = `SYSTEM: STAGE 4 TRIGGER. Ask about user's sleep habits. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set a bedtime reminder.`
|
|
stage5 = `SYSTEM: STAGE 5 TRIGGER. Ask if user reads books or mostly consumes short-form content. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set a reading reminder.`
|
|
stage6 = `SYSTEM: STAGE 6 TRIGGER. Ask about exercise/sports. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set a workout reminder.`
|
|
stage7 = `SYSTEM: STAGE 7 TRIGGER. Ask if user is satisfied with their job/career. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to help with goal planning reminders.`
|
|
stage8 = `SYSTEM: STAGE 8 TRIGGER. Ask about user's personal goals. If now is not a good time, create a non-system notification for this evening or another convenient time. Offer to set goal-tracking reminders.`
|
|
|
|
complete = `SYSTEM: COMPLETED INTEGRATION`
|
|
)
|
|
|
|
const (
|
|
d24 = 24 * time.Hour
|
|
d48 = 48 * time.Hour
|
|
d60 = 60 * time.Hour
|
|
d84 = 84 * time.Hour
|
|
d108 = 108 * time.Hour
|
|
d120 = 120 * time.Hour
|
|
)
|
|
|
|
func Collect(user *user.User, _, content string, _ ...any) actions.Action {
|
|
if user.Timezone == "" {
|
|
return nil
|
|
}
|
|
for _, fact := range user.Facts {
|
|
if fact.Value == complete {
|
|
return nil
|
|
}
|
|
}
|
|
for _, notif := range user.IncomingNotifications {
|
|
if strings.HasPrefix(strings.ToLower(notif.Content), "system") {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
if !strings.HasPrefix(content, "SYSTEM: STAGE") {
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d48), user.Timezone),
|
|
Content: stage1,
|
|
}
|
|
}
|
|
|
|
switch content[14] {
|
|
case '1':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d48), user.Timezone),
|
|
Content: stage2,
|
|
}
|
|
case '2':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d24), user.Timezone),
|
|
Content: stage3,
|
|
}
|
|
case '3':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d24), user.Timezone),
|
|
Content: stage4,
|
|
}
|
|
case '4':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d60), user.Timezone),
|
|
Content: stage5,
|
|
}
|
|
case '5':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d84), user.Timezone),
|
|
Content: stage6,
|
|
}
|
|
case '6':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d108), user.Timezone),
|
|
Content: stage7,
|
|
}
|
|
case '7':
|
|
return actions.AddNotification{
|
|
Type: "add_notification",
|
|
Time: timeconv.ToLocal(time.Now().Add(d120), user.Timezone),
|
|
Content: stage8,
|
|
}
|
|
default:
|
|
return actions.AddFact{
|
|
Type: "add_fact",
|
|
Value: complete,
|
|
}
|
|
}
|
|
}
|