-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodayReminders.ts
37 lines (34 loc) · 1.4 KB
/
todayReminders.ts
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
37
import { EventFetcher } from "../../scripts";
import { Placeholder, PlaceholderCategory, PlaceholderType } from "../../types";
/**
* Placeholder for a comma-separated list of the name and due date/time of all reminders that are scheduled over the next 24 hours.
*
* Syntax: `{{todayReminders}}`
*/
const TodayRemindersPlaceholder: Placeholder = {
name: "todayReminders",
regex: /{{(todayReminders|todayTasks|todayTodos)}}/g,
apply: async (str: string, context?: { [key: string]: unknown }) => {
if (context && "todayReminders" in context) {
return {
result: context["todayReminders"] as string,
todayReminders: context["todayReminders"],
};
}
const reminders = await EventFetcher.getUpcomingEvents("reminder", 0);
return { result: reminders, todayReminders: reminders };
},
result_keys: ["todayReminders"],
constant: true,
fn: async () =>
(await TodayRemindersPlaceholder.apply("{{todayReminders}}")).result,
example:
"Tell me about my reminders today based on the following list: {{todayReminders}}.",
description:
"Replaced with a list of the name and due date/time of all reminders that are scheduled over the next 24 hours.",
hintRepresentation: "{{todayReminders}}",
fullRepresentation: "Today's Reminders",
type: PlaceholderType.Informational,
categories: [PlaceholderCategory.Calendar],
};
export default TodayRemindersPlaceholder;