2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 21:37:58 +00:00

sendlocation

This commit is contained in:
Ilias Ismanalijev 2015-07-09 13:31:23 +02:00
parent bb29db717e
commit e47fbc622e
2 changed files with 34 additions and 0 deletions

View File

@ -376,4 +376,23 @@ TelegramBot.prototype.sendChatAction = function (chatId, action) {
return this._request('sendChatAction', {qs: query}); 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; module.exports = TelegramBot;

View File

@ -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();
});
});
});
}); });