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

experimental
Yago 10 years ago
parent a330f25b5f
commit fffb129565
  1. 22
      src/telegram.js

@ -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) { protocol: 'https',
var fileURI = URL.format({ host: 'api.telegram.org',
protocol: 'https', pathname: '/file/bot' + self.token + '/' + resp.file_path
host: 'api.telegram.org', });
pathname: '/file/bot' + bot.token + '/' + resp.file_path });
});
resolve(fileURI);
})
});
}; };
module.exports = TelegramBot; module.exports = TelegramBot;

Loading…
Cancel
Save