Created
January 20, 2019 09:39
-
-
Save kurone-kito/66d30719a29516c74d9d525621319b31 to your computer and use it in GitHub Desktop.
Script for AWS Lambda: To judge if at night and to pass the result to the Webhooks of IFTTT.
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
const https = require('https'); | |
const ifttt = event => `https://maker.ifttt.com/trigger/${event}/with/key/${process.env.IFTTT_WEBHOOK_KEY}`; | |
exports.handler = async (event) => { | |
const time = new Date(); | |
const valid = time.getHours() >= 18; | |
const eventId = valid ? 'night' : 'other'; | |
await new Promise(r => https.get(ifttt(eventId), r)); | |
const response = { statusCode: 200, body: eventId }; | |
return response; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment