This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
44 lines (41 loc) · 1.39 KB
/
script.js
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
38
39
40
41
42
43
44
class Script {
getDuration(startTime, endTime) {
return (endTime - startTime) / 60000;
}
process_incoming_request({ request }) {
const maxAttendees = 5;
const event = request.content;
let msg = "### Upcoming Event\n";
let startTime = Date.parse(event.start.dateTime);
let endTime = Date.parse(event.end.dateTime);
msg +=
`*Summary:* ${event.summary}\n` +
`*Start Time:* ${Date(startTime).toString()}\n` +
`*End Time:* ${Date(endTime).toString()}\n` +
`*Duration:* ${this.getDuration(startTime, endTime)} minutes\n` +
`*Due In:* ${Math.floor(
this.getDuration(+new Date(), startTime)
)} minutes\n` +
`${
event.attendees
? event.attendees.length > maxAttendees
? `*Attendees:* ${event.attendees.length} attendees\n`
: `*Attendees:* ${event.attendees
.map((attendee) =>
attendee.displayName ? attendee.displayName : attendee.email
)
.join(", ")}\n`
: ""
}` +
`*Calendar Link:* ${event.htmlLink}\n` +
`${event.hangoutLink ? `*Meet Link:* ${event.hangoutLink}\n` : ""}` +
`${event.location ? `*Location:* ${event.location}\n` : ""}` +
`${event.description ? `*Description:* ${event.description}\n` : ""}` +
`\n`;
return {
content: {
text: msg,
},
};
}
}