From bb3aa0f7934431e3c5ed988033bc9c379808f87c Mon Sep 17 00:00:00 2001 From: denisx Date: Wed, 13 Jul 2016 17:00:53 +0300 Subject: [PATCH] add "sendContact" from Bot.API todo: add jsdoc desc --- lib/Bot.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/Bot.js b/lib/Bot.js index 7cad17f..33e2284 100644 --- a/lib/Bot.js +++ b/lib/Bot.js @@ -492,6 +492,37 @@ Bot.prototype.sendMessage = function (options, callback) { return deferred.promise.nodeify(callback); }; +// https://tlgrm.ru/docs/bots/api#sendcontact +Bot.prototype.sendContact = function (options, callback) { + var self = this + , deferred = Q.defer(); + + this._get({ + method: 'sendContact', + params: { + chat_id: options.chat_id, + phone_number: options.phone_number, + first_name: options.first_name, + last_name: options.last_name, + disable_notification: options.disable_notification, + reply_to_message_id: options.reply_to_message_id, + reply_markup: JSON.stringify(options.reply_markup) + } + }, function (err, res) { + if (err) { + return deferred.reject(err); + } + + if (res.ok) { + deferred.resolve(res.result); + } else { + deferred.reject(res); + } + }); + + return deferred.promise.nodeify(callback); +}; + /** * Use this method to forward messages of any kind. *