Skip to content

Instantly share code, notes, and snippets.

@h4
Created October 26, 2015 09:00
Show Gist options
  • Save h4/e81456d1205313c9287c to your computer and use it in GitHub Desktop.
Save h4/e81456d1205313c9287c to your computer and use it in GitHub Desktop.
Спискок всех каналов слака
function getChannelsList(callback) {
var url = 'https://slack.com/api/channels.list?token=' + authToken + '&exclude_archived=1';
request.get(url, function (error, httpResponse, body) {
if (error) {
callback(null, error);
}
var response = JSON.parse(body);
var channels = response.channels.map(function (channel) {
return {
id: channel.id,
name: channel.name,
purpose: channel.purpose.value
}
});
callback(channels);
});
}
app.post('/', function (request, response) {
var email = request.body.email;
var channels = request.body.channels;
getChannelsList(function (channels, error) {
if (error) {
response.render('pages/error', {
error: getMessage(error)
});
} else {
response.render('pages/channels', {
email: email,
channels: channels
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment