參考網址 :https://happyplayblogs.blogspot.com/2021/09/line-notify-google.html
建立一個google script內容如下
申請一個line notify 權杖
const NotifyToken = ''; // Line Notify 權杖
//const calendar = CalendarApp.getDefaultCalendar();
//某一個月曆
const calendar
=
const calendar = CalendarApp.getCalendarById('日曆ID');
function Notify() {
Now = new Date();
Start = new Date(new Date().setHours(0, 0, 0, 0));
End = new Date(new Date().setHours(23, 59, 59, 999));
calendarData = calendar.getEvents(Now, End);
if (calendarData.length > 0) {
var NotifyContents = '今日共' + calendarData.length + "筆待執行活動\n";
calendarData.forEach(item =>{
if (Now <= item.getStartTime()) {
var year = item.getStartTime().getFullYear();
var month = item.getStartTime().getMonth()+1;
var day =item.getStartTime().getDate();
var hour = item.getStartTime().getHours();
var minute = item.getStartTime().getMinutes();
startTime = year + "/"+ month + "/" + day + " " + hour + ":" + minute
NotifyContents += "\n標題:" + ((item.getTitle() != "") ? (item.getTitle()) : ("無標題")) + "\n";
NotifyContents += "開始時間:" + startTime + "\n";
}
})
Logger.log(NotifyContents)
UrlFetchApp.fetch("https://notify-api.line.me/api/notify", {
"method" : "post",
"payload" : {"message" : NotifyContents},
"headers" : {"Authorization" : "Bearer " + NotifyToken}
});
}
}
執行時要允許授權
google script是可以設定觸發條件