Merge branch 'Illyism-master'

experimental
yago 11 years ago
commit e77ca6fef8
  1. 17
      README.md
  2. 19
      src/telegram.js
  3. 15
      test/index.js

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

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

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

Loading…
Cancel
Save