From 4192d38ec127277fb865cc57dfeb63e3a7281bf5 Mon Sep 17 00:00:00 2001 From: Ilias Ismanalijev Date: Thu, 9 Jul 2015 13:59:23 +0200 Subject: [PATCH] get user profile photos --- src/telegram.js | 19 +++++++++++++++++++ test/index.js | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index cf9f0ba..a1bebc7 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -376,4 +376,23 @@ TelegramBot.prototype.sendChatAction = function (chatId, action) { return this._request('sendChatAction', {qs: query}); }; +/** + * Use this method to get a list of profile pictures for a user. + * Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object. + * + * @param {Number|String} userId Unique identifier of the target user + * @param {Number} [offset] Sequential number of the first photo to be returned. By default, all photos are returned. + * @param {Number} [limit] Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. + * @return {Promise} + * @see https://core.telegram.org/bots/api#getuserprofilephotos + */ +TelegramBot.prototype.getUserProfilePhotos = function (userId, offset, limit) { + var query = { + user_id: userId, + offset: offset, + limit: limit + }; + return this._request('getUserProfilePhotos', {qs: query}); +}; + module.exports = TelegramBot; diff --git a/test/index.js b/test/index.js index 13326b7..27991f3 100644 --- a/test/index.js +++ b/test/index.js @@ -322,4 +322,16 @@ describe('Telegram', function () { }); }); + describe('#getUserProfilePhotos', function () { + it('should get user profile photos', function (done) { + var bot = new Telegram(TOKEN); + bot.getUserProfilePhotos(USERID).then(function (resp) { + resp.should.be.an.instanceOf(Object); + resp.total_count.should.be.an.instanceOf(Number); + resp.photos.should.be.an.instanceOf(Array); + done(); + }); + }); + }); + });