diff --git a/README.md b/README.md index 19a9d0b..79b6c78 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ TelegramBot * [.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 + * [.sendContact(chatId, phone_number, first_name, [options])](#TelegramBot+sendContact) ⇒ Promise * [.getFile(fileId)](#TelegramBot+getFile) ⇒ Promise * [.getFileLink(fileId)](#TelegramBot+getFileLink) ⇒ Promise * [.downloadFile(fileId, downloadDir)](#TelegramBot+downloadFile) ⇒ Promise @@ -115,7 +116,7 @@ Emits `message` when a message arrives. | [options.webHook] | Boolean | Object | false | Set true to enable WebHook or set options | | [options.webHook.key] | String | | PEM private key to webHook server. | | [options.webHook.cert] | String | | PEM certificate (public) to webHook server. | -| [options.onlyFirstMatch] | Boolean | false | false: try matching all regexps; true: stop after first match | +| [options.onlyFirstMatch] | Boolean | false | Set to true to stop after first match. Otherwise, all regexps are executed | @@ -456,6 +457,22 @@ Use this method to send information about a venue. | address | String | Address of the venue | | [options] | Object | Additional Telegram query options | + + +### telegramBot.sendContact(chatId, phone_number, first_name, [options]) ⇒ Promise +Send contact. +Use this method to send phone contacts. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendcontact + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | String | Unique identifier for the message recipient | +| phone_number | String | Contact's phone number | +| first_name | String | Contact's first name | +| [options] | Object | Additional Telegram query options | + ### telegramBot.getFile(fileId) ⇒ Promise diff --git a/src/telegram.js b/src/telegram.js index 3b51349..132c6b9 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -669,6 +669,25 @@ class TelegramBot extends EventEmitter { return this._request('sendVenue', { form }); } + /** + * Send contact. + * Use this method to send phone contacts. + * + * @param {Number|String} chatId Unique identifier for the message recipient + * @param {String} phone_number Contact's phone number + * @param {String} first_name Contact's first name + * @param {Object} [options] Additional Telegram query options + * @return {Promise} + * @see https://core.telegram.org/bots/api#sendcontact + */ + sendContact(chatId, phoneNumber, firstName, form = {}) { + form.chat_id = chatId; + form.phone_number = phoneNumber; + form.first_name = firstName; + return this._request('sendContact', { form }); + } + + /** * Get file. * Use this method to get basic info about a file and prepare it for downloading.