Skip to content

Commit

Permalink
Add missing parameters to answerInlineQuery and implement exportChatI…
Browse files Browse the repository at this point in the history
…nviteLink method (#58)

* Added missing parameters to answerInlineQuery method

* Implemented exportChatInviteLink method

* Fix runaway promise warning

Not returning any value in the promise chain resulted in a warning like
this:

(node:165) Warning: a promise was created in a handler at app/node_modules/telegram-bot-api/lib/telegram-bot.js:1680:13 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (/app/node_modules/bluebird/js/release/promise.js:79:10)
  • Loading branch information
acran authored and mast committed Feb 1, 2019
1 parent 3575557 commit 86e0cda
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ editMessageCaption
editMessageReplyMarkup
kickChatMember
unbanChatMember
exportChatInviteLink
leaveChat
getChat
getChatAdministrators
Expand Down
31 changes: 31 additions & 0 deletions lib/telegram-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,8 @@ var TelegramApi = function (params)
if (params.cache_time !== undefined) args.cache_time = params.cache_time;
if (params.is_personal !== undefined) args.is_personal = params.is_personal;
if (params.next_offset !== undefined) args.next_offset = params.next_offset;
if (params.switch_pm_text !== undefined) args.switch_pm_text = params.switch_pm_text;
if (params.switch_pm_parameter !== undefined) args.switch_pm_parameter = params.switch_pm_parameter;

_rest({
method: 'POST',
Expand Down Expand Up @@ -1573,6 +1575,34 @@ var TelegramApi = function (params)
}).nodeify(cb);
};

/**
* METHOD: exportChatInviteLink
* PARAMS:
* chat_id Unique identifier for the target chat or username of the target channel — User or GroupChat id
*/
this.exportChatInviteLink = function (params, cb) {
var args = {};

if (params.chat_id !== undefined) args.chat_id = params.chat_id;

return new Promise(function(resolve, reject) {
_rest({
method: 'POST',
json: true,
formData: args,
uri: _baseurl + 'exportChatInviteLink'
})
.then(function(body) {
return commonResponseHandler(body);
})
.then(function(data) {
resolve(data);
})
.catch(function(err) {
reject(err);
});
}).nodeify(cb);
};

/**
* METHOD: deleteMessage
Expand Down Expand Up @@ -1648,6 +1678,7 @@ var TelegramApi = function (params)
this.deleteWebhook()
.then(function() {
internalGetUpdates();
return null; // avoid runaway promise warning, see http://goo.gl/rRqMUw
})
.catch(function(err) {
throw new Error(err)
Expand Down

0 comments on commit 86e0cda

Please sign in to comment.