Last active
January 27, 2024 14:10
-
-
Save neno-tech/13583358d93a4b3294f09015cab37c8d to your computer and use it in GitHub Desktop.
Google Form + Line Notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ครูอภิวัฒน์ "สอนสร้างสื่อ" | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
getLastRow didn't work