-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.gs
37 lines (33 loc) · 894 Bytes
/
Setup.gs
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
/**
* Setup the triggers and install the app on the current google account.
*/
function install() {
deleteAllTriggers();
const resetDate = new Date();
resetDate.setHours(24, 0, 0, 0);
eventCalendar = initCalendar(jsonSettings.eventCalendarName);
alarmCalendar = initCalendar(jsonSettings.alarmCalendarName);
ScriptApp.newTrigger("main")
.forUserCalendar(eventCalendar.getId())
.onEventUpdated()
.create();
ScriptApp.newTrigger("main")
.forUserCalendar(alarmCalendar.getId())
.onEventUpdated()
.create();
ScriptApp.newTrigger("main").timeBased().after(1).create();
ScriptApp.newTrigger("reset")
.timeBased()
.atHour(0)
.nearMinute(0)
.everyDays(1)
.create();
Logger.log("Installation complete.");
}
/**
* Fully uninstall the app.
*/
function uninstall() {
deleteAllTriggers();
Logger.log("Uninstallation complete.");
}