From e47fbc622eec2028e0ef3773fbb3b50ec0aabbb1 Mon Sep 17 00:00:00 2001 From: Ilias Ismanalijev Date: Thu, 9 Jul 2015 13:31:23 +0200 Subject: [PATCH] sendlocation --- src/telegram.js | 19 +++++++++++++++++++ test/index.js | 15 +++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index cf9f0ba..2aab978 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}); }; +/** + * Send location. + * Use this method to send point on the map. + * + * @param {Number|String} chatId Unique identifier for the message recipient + * @param {Float} latitude Latitude of location + * @param {Float} longitude Longitude of location + * @return {Promise} + * @see https://core.telegram.org/bots/api#sendlocation + */ +TelegramBot.prototype.sendLocation = function (chatId, latitude, longitude) { + var query = { + chat_id: chatId, + latitude: latitude, + longitude: longitude + }; + return this._request('sendLocation', {qs: query}); +}; + module.exports = TelegramBot; diff --git a/test/index.js b/test/index.js index 13326b7..73d079c 100644 --- a/test/index.js +++ b/test/index.js @@ -322,4 +322,19 @@ describe('Telegram', function () { }); }); + describe('#sendLocation', function () { + it('should send a location', function (done) { + var bot = new Telegram(TOKEN); + var lat = 47.5351072; + var long = -52.7508537; + bot.sendLocation(USERID, lat, long).then(function (resp) { + resp.should.be.an.instanceOf(Object); + resp.location.should.be.an.instanceOf(Object); + resp.location.latitude.should.be.an.instanceOf(Number); + resp.location.longitude.should.be.an.instanceOf(Number); + done(); + }); + }); + }); + });