diff --git a/README.md b/README.md index 2a0fb08..d0ffaa1 100644 --- a/README.md +++ b/README.md @@ -208,4 +208,21 @@ See: https://core.telegram.org/bots/api#sendchataction * **Promise** +## sendLocation(chatId, latitude, longitude, [options]) + +Use this method to send point on the map. + +See: https://core.telegram.org/bots/api#sendlocation + +### Params: + +* **Number|String** *chatId* Unique identifier for the message recipient +* **Float** *latitude* Latitude of location +* **Float** *longitude* Longitude of location +* **Object** *[options]* Additional Telegram query options + +### Return: + +* **Promise** + diff --git a/src/telegram.js b/src/telegram.js index a1bebc7..d2b2445 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -395,4 +395,23 @@ TelegramBot.prototype.getUserProfilePhotos = function (userId, offset, limit) { return this._request('getUserProfilePhotos', {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 + * @param {Object} [options] Additional Telegram query options + * @return {Promise} + * @see https://core.telegram.org/bots/api#sendlocation + */ +TelegramBot.prototype.sendLocation = function (chatId, latitude, longitude, options) { + var query = options || {}; + query.chat_id = chatId; + query.latitude = latitude; + query.longitude = longitude; + return this._request('sendLocation', {qs: query}); +}; + module.exports = TelegramBot; diff --git a/test/index.js b/test/index.js index 27991f3..af5aa98 100644 --- a/test/index.js +++ b/test/index.js @@ -334,4 +334,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(); + }); + }); + }); + +}); // End Telegram