-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
27 lines (24 loc) · 834 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//warning this may trigger multiple times for one press
//...usually triggers twice based on testing for each press
var dash_button = require('node-dash-button');
var address = process.env.DASH_ADDRESS || '';
var dash = dash_button(address, null, null, 'all');
var IncomingWebhook = require('@slack/client').IncomingWebhook;
var url = process.env.SLACK_WEBHOOK_URL || '';
var webhook = new IncomingWebhook(url);
var twelveMins = 12 * 60 * 1000 // 12 minutes to brew a pot
dash.on("detected", function (){
payload={
"text": "Fresh pot of coffee is ready! :coffeemug:"
}
sendWebhook = function () {
webhook.send(payload, function(err, res) {
if (err) {
console.log('Error:', err);
} else {
console.log('Message sent: ', res);
}
});
}
setTimeout(sendWebhook, twelveMins);
});