Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function main_send_all() {
- const ss = SpreadsheetApp.openByUrl('url таблицы');
- const sh = ss.getSheetByName('//');
- const now = new Date();
- const hour = now.getHours();
- const values = sh.getDataRange().getValues();
- const botToken = values[1][10];
- for (var row = 2; row < values.length; row++) {
- const x = values[row];
- const [url, sheetRange, ids, subj, freq, hours, format, last] = [x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]];
- const [day, hour] = [now.getDay() ? now.getDay() : 7, now.getHours().toString()];
- if (x.length > 5
- // && freq.indexOf(day) != -1
- // && hours.toString().split(';').filter(g => g == hour).length
- // && (!last || d2s(last) != d2s(now))
- ){
- const ss0 = SpreadsheetApp.openByUrl(x[0]);
- const blob = toPdf(ss0, sheetRange);
- let r;
- ids.split(",").forEach(h => {
- if (!format || format == 'JPG') { r = sendPhoto(h, blob, botToken, subj) }
- else if (format == 'PDF') { r = sendDoc(h, blob, botToken, subj) }
- });
- sh.getRange(row + 1, 8, 1, 2).setValues([[new Date(), JSON.parse(r).ok == true ? '' : r]]);
- }
- SpreadsheetApp.flush();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement