2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-30 13:58:27 +00:00

Better chain a 'then' on the getFile promise and return it.

This commit is contained in:
Yago
2015-09-26 19:25:57 +02:00
parent a330f25b5f
commit fffb129565

View File

@@ -428,19 +428,15 @@ TelegramBot.prototype.getFile = function(fileId) {
*/ */
TelegramBot.prototype.getFileLink = function(fileId) { TelegramBot.prototype.getFileLink = function(fileId) {
var bot = this; var self = this;
return self.getFile(fileId).then(function (resp) {
return new Promise(function(resolve) { return URL.format({
bot.getFile(fileId).then(function(resp) {
var fileURI = URL.format({
protocol: 'https', protocol: 'https',
host: 'api.telegram.org', host: 'api.telegram.org',
pathname: '/file/bot' + bot.token + '/' + resp.file_path pathname: '/file/bot' + self.token + '/' + resp.file_path
});
}); });
resolve(fileURI);
})
});
}; };
module.exports = TelegramBot; module.exports = TelegramBot;