-
Notifications
You must be signed in to change notification settings - Fork 0
/
lebanonTriggers.gs
36 lines (33 loc) · 1.77 KB
/
lebanonTriggers.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
function makeAllTriggers() {
const triggerList = [
//Lebanon Hours
{ name: 'OpenLebDevsOnMonday', func: 'openLebDevs', day: 'MONDAY', hour: '9', minute: '40' },
{ name: 'CloseLebDevsOnMonday', func: 'closeLebDevs', day: 'MONDAY', hour: '20', minute: '5' },
{ name: 'OpenLebDevsOnTuesday', func: 'openLebDevs', day: 'TUESDAY', hour: '9', minute: '40' },
{ name: 'CloseLebDevsOnTuesday', func: 'closeLebDevs', day: 'TUESDAY', hour: '20', minute: '5' },
{ name: 'OpenLebDevsOnWednesday', func: 'openLebDevs', day: 'WEDNESDAY', hour: '9', minute: '40' },
{ name: 'CloseLebDevsOnWednesday', func: 'closeLebDevs', day: 'WEDNESDAY', hour: '20', minute: '5' },
{ name: 'OpenLebDevsOnThursday', func: 'openLebDevs', day: 'THURSDAY', hour: '9', minute: '40' },
{ name: 'CloseLebDevsOnThursday', func: 'closeLebDevs', day: 'THURSDAY', hour: '20', minute: '5' },
{ name: 'OpenLebDevsOnFriday', func: 'openLebDevs', day: 'FRIDAY', hour: '9', minute: '40' },
{ name: 'CloseLebDevsOnFriday', func: 'closeLebDevs', day: 'FRIDAY', hour: '17', minute: '5' },
{ name: 'OpenLebDevsOnSaturday', func: 'openLebDevs', day: 'SATURDAY', hour: '9', minute: '40' },
{ name: 'CloseLebDevsOnSaturday', func: 'closeLebDevs', day: 'SATURDAY', hour: '17', minute: '5' }
]
triggerList.forEach(trigger => makeTrigger(trigger));
}
function makeTrigger(trigs) {
const { name, func, day, hour, minute } = trigs;
Logger.log(`Creating trigger ${name}.`);
ScriptApp.newTrigger(func)
.timeBased()
.onWeekDay(ScriptApp.WeekDay[day])
.atHour(hour)
.nearMinute(minute)
.inTimezone('America/New_York')
.create();
}
function deleteAllTriggers() {
const allTriggers = ScriptApp.getProjectTriggers();
allTriggers.map(trigger => ScriptApp.deleteTrigger(trigger))
}