Created
October 26, 2015 09:00
-
-
Save h4/e81456d1205313c9287c to your computer and use it in GitHub Desktop.
Спискок всех каналов слака
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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