Skip to content

Commit

Permalink
Merge pull request #77 from denisx/patch-1
Browse files Browse the repository at this point in the history
add "sendContact" from Bot.API
  • Loading branch information
shernshiou committed Jul 14, 2016
2 parents 0964831 + bb3aa0f commit 0abe096
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/Bot.js
Expand Up @@ -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.
*
Expand Down

0 comments on commit 0abe096

Please sign in to comment.