diff --git a/README.md b/README.md index 9017078..a9d5bd6 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ TelegramBot * [new TelegramBot(token, [options])](#new_TelegramBot_new) * [.stopPolling()](#TelegramBot+stopPolling) ⇒ Promise * [.getMe()](#TelegramBot+getMe) ⇒ Promise - * [.getChat()](#TelegramBot+getChat) ⇒ Promise + * [.getChat(chatId)](#TelegramBot+getChat) ⇒ Promise * [.setWebHook(url, [cert])](#TelegramBot+setWebHook) * [.getUpdates([timeout], [limit], [offset])](#TelegramBot+getUpdates) ⇒ Promise * [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ Promise @@ -81,6 +81,7 @@ TelegramBot * [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ Promise * [.getUserProfilePhotos(userId, [offset], [limit])](#TelegramBot+getUserProfilePhotos) ⇒ Promise * [.sendLocation(chatId, latitude, longitude, [options])](#TelegramBot+sendLocation) ⇒ Promise + * [.sendVenue(chatId, latitude, longitude, title, address, [options])](#TelegramBot+sendVenue) ⇒ Promise * [.getFile(fileId)](#TelegramBot+getFile) ⇒ Promise * [.getFileLink(fileId)](#TelegramBot+getFileLink) ⇒ Promise * [.downloadFile(fileId, downloadDir)](#TelegramBot+downloadFile) ⇒ Promise @@ -122,13 +123,18 @@ Returns basic information about the bot in form of a `User` object. **See**: https://core.telegram.org/bots/api#getme -### telegramBot.getChat() ⇒ Promise +### telegramBot.getChat(chatId) ⇒ Promise Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). **Kind**: instance method of [TelegramBot](#TelegramBot) **See**: https://core.telegram.org/bots/api#getchat + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | String | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) | + ### telegramBot.setWebHook(url, [cert]) @@ -436,6 +442,24 @@ Use this method to send point on the map. | longitude | Float | Longitude of location | | [options] | Object | Additional Telegram query options | + + +### telegramBot.sendVenue(chatId, latitude, longitude, title, address, [options]) ⇒ Promise +Send venue. +Use this method to send information about a venue. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendvenue + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | String | Unique identifier for the message recipient | +| latitude | Float | Latitude of location | +| longitude | Float | Longitude of location | +| title | String | Name of the venue | +| address | String | Address of the venue | +| [options] | Object | Additional Telegram query options | + ### telegramBot.getFile(fileId) ⇒ Promise diff --git a/src/telegram.js b/src/telegram.js index d82e06b..49eaacb 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -140,7 +140,7 @@ class TelegramBot extends EventEmitter { throw new Error(`Error parsing Telegram response: ${String(json)}`); } } - + _fixReplyMarkup(obj) { const replyMarkup = obj.reply_markup; if (replyMarkup && typeof replyMarkup !== 'string') { @@ -209,6 +209,7 @@ class TelegramBot extends EventEmitter { * Use this method to get up to date information about the chat * (current name of the user for one-on-one conversations, current * username of a user, group or channel, etc.). + * @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) * @return {Promise} * @see https://core.telegram.org/bots/api#getchat */ @@ -216,8 +217,7 @@ class TelegramBot extends EventEmitter { const form = { chat_id: chatId }; - - return this._request('getChat', {form: form}); + return this._request('getChat', { form }); } /** @@ -648,7 +648,7 @@ class TelegramBot extends EventEmitter { form.longitude = longitude; return this._request('sendLocation', { form }); } - + /** * Send venue. * Use this method to send information about a venue. diff --git a/test/index.js b/test/index.js index defefd2..cf4b0a4 100644 --- a/test/index.js +++ b/test/index.js @@ -131,8 +131,8 @@ describe('Telegram', function telegramSuite() { }); }); - describe('#getChat', function getMeSuite() { - it('should return an User object', function test() { + describe('#getChat', function getChatSuite() { + it('should return a Chat object', function test() { const bot = new Telegram(TOKEN); return bot.getChat(USERID).then(resp => { assert.ok(is.object(resp));