-
Notifications
You must be signed in to change notification settings - Fork 0
/
Web.gs
34 lines (29 loc) · 778 Bytes
/
Web.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
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}
function getTriggerCount() {
return ScriptApp.getProjectTriggers().length
}
function removeAllTriggers() {
const triggers = ScriptApp.getProjectTriggers()
for (let trigger of triggers) {
ScriptApp.deleteTrigger(trigger)
}
}
function addTrigger(weekly) {
let trigger = ScriptApp.newTrigger('main').timeBased()
if (weekly) {
trigger = trigger.everyWeeks(1).onWeekDay(ScriptApp.WeekDay.MONDAY)
} else {
trigger = trigger.onMonthDay(1);
}
trigger.atHour(0).create();
}
function getUsedSpreadsheetID() {
return new DB().spreadsheetID || false
}
function configureAndRun(cfg) {
customConfig = cfg.custom
if (!cfg.once) addTrigger(cfg.weekly)
return mainWrapper()
}