-
Notifications
You must be signed in to change notification settings - Fork 1
/
hipchat.js
43 lines (39 loc) · 1.3 KB
/
hipchat.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Generated by CoffeeScript 1.6.1
var hipchat, https, querystring;
querystring = require('querystring');
https = require('https');
hipchat = function() {
var api_params, api_url, departed, leaving, public_methods, send_message;
api_url = "https://api.hipchat.com/v1/rooms/message";
api_params = {
format: 'json',
auth_token: '1cd513768bb3823d484d836ca167f9',
notify: 1,
message_format: 'text',
room_id: 190791
};
send_message = function(message, isUrgent) {
var url;
api_params.from = isUrgent ? "Train alert!" : "Train alert";
api_params.color = isUrgent ? "red" : "yellow";
api_params.message = message;
url = api_url + "?" + querystring.stringify(api_params);
console.log("hipchat message: " + message);
return https.get(url, function(res) {
return console.log("hipchat response: " + res.statusCode);
}).on('error', function(e) {
return console.log("hipchat error: " + e.message);
});
};
leaving = function() {
return send_message("Watch out, the Sandwich Train is leaving in 2 minutes. Hurry up!", false);
};
departed = function() {
return send_message("Watch out, the Sandwich Train is leaving right NOW!", true);
};
return public_methods = {
leaving: leaving,
departed: departed
};
};
module.exports = hipchat();