-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest.js
34 lines (28 loc) · 794 Bytes
/
rest.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
var express = require('express');
module.exports = function(slack, slackUsers, slackChannels) {
var router = express.Router();
router.get('/users', function(req, res) {
res.send(slackUsers);
});
router.get('/channels', function(req, res) {
res.send(slackChannels);
});
router.get('/messages/send', function(req, res) {
var slackChannel = slack.getChannelByName(req.query.channel);
slackChannel.send(req.query.message);
res.send();
});
router.get('/messages/bot/send', function (req, res) {
slack._apiCall('chat.postMessage',
{
'token': req.query.token,
'channel': req.query.channel,
'text': req.query.message
},
function(data) {
console.log(data);
});
res.send();
});
return router;
};