2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

Merge branch 'Illyism-master'

This commit is contained in:
yago 2015-07-09 23:13:28 +02:00
commit e77ca6fef8
3 changed files with 52 additions and 1 deletions

View File

@ -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**
<!-- End src/telegram.js -->

View File

@ -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;

View File

@ -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