-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreminder.go
36 lines (29 loc) · 853 Bytes
/
reminder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import "strings"
const REMIND_ME = "remind me to"
const ALARMING_TIME_PREFIX = "on"
func remindMe(msg string) string {
var content string
time := ""
response := "Will remind you to "
if len(REMIND_ME) > len(msg) {
return ""
}
afterPrefix := strings.TrimPrefix(msg, REMIND_ME+" ")
// TODO: Handle M"on"day
alarmingSuffixIndex := strings.LastIndex(afterPrefix, ALARMING_TIME_PREFIX)
if alarmingSuffixIndex > -1 {
content = afterPrefix[:alarmingSuffixIndex-1]
time = extractTime(afterPrefix[alarmingSuffixIndex+len(ALARMING_TIME_PREFIX):])
// TODO: Create reminder on specified time
response = response + content + ": on " + time
} else {
// TODO: Ask for the time
content = afterPrefix
response = response + content
}
return response
}
func extractTime(msg string) string {
return strings.Trim(msg, " ")
}