From 9d25ceb3c47c71c17e3290d570c24d7cdeea0157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Fri, 6 May 2016 21:03:04 +0300 Subject: [PATCH 1/2] add the sendVenue method This method was added to the Telegram Bot API on April 9, 2016 in the Bot API 2.0 update. See https://core.telegram.org/bots/api#sendvenue for more info. --- src/telegram.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index c58447d..79b61d6 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -490,6 +490,28 @@ class TelegramBot extends EventEmitter { form.longitude = longitude; return this._request('sendLocation', { form }); } + + /** + * Send venue. + * Use this method to send information about a venue. + * + * @param {Number|String} chatId Unique identifier for the message recipient + * @param {Float} latitude Latitude of location + * @param {Float} longitude Longitude of location + * @param {String} title Name of the venue + * @param {String} address Address of the venue + * @param {Object} [options] Additional Telegram query options + * @return {Promise} + * @see https://core.telegram.org/bots/api#sendvenue + */ + sendVenue(chatId, latitude, longitude, title, address, form = {}) { + form.chat_id = chatId; + form.latitude = latitude; + form.longitude = longitude; + form.title = title; + form.address = address; + return this._request('sendVenue', { form }); + } /** * Get file. From 5633aa97bdde16e3b0f60f51bc87239e80107639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Fri, 6 May 2016 21:05:47 +0300 Subject: [PATCH 2/2] add test for the sendVenue method This test uses the same location as the #sendLocation test, while providing info on the venue (The Village Shopping Centre). --- test/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/index.js b/test/index.js index d8c813a..0952390 100644 --- a/test/index.js +++ b/test/index.js @@ -394,6 +394,24 @@ describe('Telegram', function telegramSuite() { }); }); }); + + describe('#sendVenue', function sendVenueSuite() { + it('should send a venue', function test() { + const bot = new Telegram(TOKEN); + const lat = 47.5351072; + const long = -52.7508537; + const title = `The Village Shopping Centre`; + const address = `430 Topsail Rd,St. John's, NL A1E 4N1, Canada`; + return bot.sendVenue(USERID, lat, long, title, address).then(resp => { + assert.ok(is.object(resp)); + assert.ok(is.object(resp.location)); + assert.ok(is.number(resp.location.latitude)); + assert.ok(is.number(resp.location.longitude)); + assert.ok(is.string(resp.title)); + assert.ok(is.string(resp.address)); + }); + }); + }); describe('#getFile', function getFileSuite() { let fileId;