Skip to content

Instantly share code, notes, and snippets.

@neno-tech
Last active January 27, 2024 14:10
Show Gist options
  • Save neno-tech/13583358d93a4b3294f09015cab37c8d to your computer and use it in GitHub Desktop.
Save neno-tech/13583358d93a4b3294f09015cab37c8d to your computer and use it in GitHub Desktop.
Google Form + Line Notify
//ครูอภิวัฒน์ "สอนสร้างสื่อ"
function myFunction() {
var token = 'xxx'
var ss = SpreadsheetApp.openById('xxx')
var sh = ss.getSheetByName('xxx')
var row = sh.getLastRow();
var today = Utilities.formatDate(new Date(), "GMT+7", "dd/MM/yyyy")
var time = Utilities.formatDate(new Date(), "GMT+7", "HH:mm")
Logger.log(time)
for (i = 2; i <= row; i++) {
var date = Utilities.formatDate(sh.getRange(i, 2).getValue(), "GMT+7", "dd/MM/yyyy")
var timer = sh.getRange(i, 3).getValue()
var imgUrl = sh.getRange(i, 5).getValue()
var imgID = imgUrl.split('https://drive.google.com/open?id=')[1]
if (today == date && time == timer) {
var msg = sh.getRange(i, 4).getValue() + '\n'
var message = '\n แจ้งเตือน : ' + msg
var image = DriveApp.getFileById(imgID).getBlob()
sendLineNotify(message,image, token)
}
}
}
function sendLineNotify(message,image, token) {
var options = {
"method": "post",
"payload": {
"message": message,
"imageFile": image,
},
"headers": { "Authorization": "Bearer " + token }
};
UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
}
@dyand123
Copy link

getLastRow didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment