exports.CountEndOfMonth = functions.pubsub.schedule("* * * * *").timeZone('Asia/Bangkok').onRun((context) => { const endDateOfMonth = moment().endOf('month').format('DD') const currentDate = moment().format('DD') let message = '' if (currentDate === endDateOfMonth) { message = `วันนี้เป็นวันสิ้นเดือนจ้า เย่เย้ ~~ 😁😁` } else { message = `อีก ${endDateOfMonth - currentDate} วัน จะสิ้นเดือน สู้สู้จ้า 🎉🎉` } request({ method: 'POST', uri: 'https://notify-api.line.me/api/notify', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, auth: { 'bearer': //คัดลอก line notify access token มาวางไว้ที่นี้ }, form: { message: message } }, (err, httpResponse, body) => { if (err) { console.log(err); } else { console.log(body) } }) })