-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbotsend.js
More file actions
34 lines (30 loc) · 808 Bytes
/
botsend.js
File metadata and controls
34 lines (30 loc) · 808 Bytes
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
module.exports = {
botresponder: function(response){
var HTTPS = require('https');
var options, body, botReq;
options = {
hostname: "api.groupme.com",
path: '/v3/bots/post',
method: 'POST'
};
//Bot ID hardcoded for now, pls change later
body = {
"bot_id" : "f9ff6c8cd993345ef70a959d01",
"text" : response
};
botReq = HTTPS.request(options, function(res){
if(res.statusCode == 202) {
//Post was successful, yay!
} else {
console.log('rejecting bad status code ' + res.statusCode);
}
});
botReq.on('error', function(err) {
console.log('Error posting mesasage ' + JSON.stringify(err));
});
botReq.on('timeout', function(err) {
console.log('timeout posting error' + JSON.stringify(err));
});
botReq.end(JSON.stringify(body));
}
};