mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-28 21:07:39 +00:00
src/telegram: Fix TelegramBot#answerCallbackQuery() signature
Bug: `callbackQueryId` is a required argument. All other options are optional. References: * Telegram API doc: https://core.telegram.org/bots/api#answercallbackquery * Blame: https://github.com/yagop/node-telegram-bot-api/pull/368
This commit is contained in:
parent
9cf36a3b20
commit
3722c7182c
@ -9,6 +9,9 @@ Added:
|
|||||||
|
|
||||||
* Add support for Node.js v9
|
* Add support for Node.js v9
|
||||||
|
|
||||||
|
Changed:
|
||||||
|
|
||||||
|
1. Update *TelegramBot#answerCallbackQuery()* signature (by @GochoMugo)
|
||||||
|
|
||||||
|
|
||||||
* * *
|
* * *
|
||||||
|
@ -16,3 +16,4 @@
|
|||||||
[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates
|
[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates
|
||||||
[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos
|
[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos
|
||||||
[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery
|
[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery
|
||||||
|
[answerCallbackQuery-v0.29.0]:https://github.com/yagop/node-telegram-bot-api/blob/v0.29.0/doc/api.md#TelegramBot+answerCallbackQuery
|
||||||
|
10
doc/api.md
10
doc/api.md
@ -49,7 +49,7 @@ TelegramBot
|
|||||||
* [.setChatDescription(chatId, description)](#TelegramBot+setChatDescription) ⇒ <code>Promise</code>
|
* [.setChatDescription(chatId, description)](#TelegramBot+setChatDescription) ⇒ <code>Promise</code>
|
||||||
* [.pinChatMessage(chatId, messageId)](#TelegramBot+pinChatMessage) ⇒ <code>Promise</code>
|
* [.pinChatMessage(chatId, messageId)](#TelegramBot+pinChatMessage) ⇒ <code>Promise</code>
|
||||||
* [.unpinChatMessage(chatId)](#TelegramBot+unpinChatMessage) ⇒ <code>Promise</code>
|
* [.unpinChatMessage(chatId)](#TelegramBot+unpinChatMessage) ⇒ <code>Promise</code>
|
||||||
* [.answerCallbackQuery([options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
|
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
|
||||||
* [.editMessageText(text, [options])](#TelegramBot+editMessageText) ⇒ <code>Promise</code>
|
* [.editMessageText(text, [options])](#TelegramBot+editMessageText) ⇒ <code>Promise</code>
|
||||||
* [.editMessageCaption(caption, [options])](#TelegramBot+editMessageCaption) ⇒ <code>Promise</code>
|
* [.editMessageCaption(caption, [options])](#TelegramBot+editMessageCaption) ⇒ <code>Promise</code>
|
||||||
* [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ <code>Promise</code>
|
* [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ <code>Promise</code>
|
||||||
@ -597,20 +597,21 @@ Returns True on success.
|
|||||||
|
|
||||||
<a name="TelegramBot+answerCallbackQuery"></a>
|
<a name="TelegramBot+answerCallbackQuery"></a>
|
||||||
|
|
||||||
### telegramBot.answerCallbackQuery([options]) ⇒ <code>Promise</code>
|
### telegramBot.answerCallbackQuery(callbackQueryId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to send answers to callback queries sent from
|
Use this method to send answers to callback queries sent from
|
||||||
inline keyboards. The answer will be displayed to the user as
|
inline keyboards. The answer will be displayed to the user as
|
||||||
a notification at the top of the chat screen or as an alert.
|
a notification at the top of the chat screen or as an alert.
|
||||||
On success, True is returned.
|
On success, True is returned.
|
||||||
|
|
||||||
This method has an [older, compatible signature][answerCallbackQuery-v0.27.1]
|
This method has **older, compatible signatures ([1][answerCallbackQuery-v0.27.1])([2][answerCallbackQuery-v0.29.0])**
|
||||||
that is being deprecated.
|
that are being deprecated.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
**See**: https://core.telegram.org/bots/api#answercallbackquery
|
**See**: https://core.telegram.org/bots/api#answercallbackquery
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
| callbackQueryId | <code>String</code> | Unique identifier for the query to be answered |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+editMessageText"></a>
|
<a name="TelegramBot+editMessageText"></a>
|
||||||
@ -1134,3 +1135,4 @@ TelegramBot.Promise = myPromise;
|
|||||||
[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates
|
[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates
|
||||||
[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos
|
[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos
|
||||||
[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery
|
[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery
|
||||||
|
[answerCallbackQuery-v0.29.0]:https://github.com/yagop/node-telegram-bot-api/blob/v0.29.0/doc/api.md#TelegramBot+answerCallbackQuery
|
||||||
|
@ -1041,15 +1041,16 @@ class TelegramBot extends EventEmitter {
|
|||||||
* a notification at the top of the chat screen or as an alert.
|
* a notification at the top of the chat screen or as an alert.
|
||||||
* On success, True is returned.
|
* On success, True is returned.
|
||||||
*
|
*
|
||||||
* This method has an [older, compatible signature][answerCallbackQuery-v0.27.1]
|
* This method has **older, compatible signatures ([1][answerCallbackQuery-v0.27.1])([2][answerCallbackQuery-v0.29.0])**
|
||||||
* that is being deprecated.
|
* that are being deprecated.
|
||||||
*
|
*
|
||||||
|
* @param {String} callbackQueryId Unique identifier for the query to be answered
|
||||||
* @param {Object} [options] Additional Telegram query options
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#answercallbackquery
|
* @see https://core.telegram.org/bots/api#answercallbackquery
|
||||||
*/
|
*/
|
||||||
answerCallbackQuery(form = {}) {
|
answerCallbackQuery(callbackQueryId, form = {}) {
|
||||||
/* The older method signature was answerCallbackQuery(callbackQueryId, text, showAlert).
|
/* The older method signature (in/before v0.27.1) was answerCallbackQuery(callbackQueryId, text, showAlert).
|
||||||
* We need to ensure backwards-compatibility while maintaining
|
* We need to ensure backwards-compatibility while maintaining
|
||||||
* consistency of the method signatures throughout the library */
|
* consistency of the method signatures throughout the library */
|
||||||
if (typeof form !== 'object') {
|
if (typeof form !== 'object') {
|
||||||
@ -1062,6 +1063,17 @@ class TelegramBot extends EventEmitter {
|
|||||||
};
|
};
|
||||||
/* eslint-enable no-param-reassign, prefer-rest-params */
|
/* eslint-enable no-param-reassign, prefer-rest-params */
|
||||||
}
|
}
|
||||||
|
/* The older method signature (in/before v0.29.0) was answerCallbackQuery([options]).
|
||||||
|
* We need to ensure backwards-compatibility while maintaining
|
||||||
|
* consistency of the method signatures throughout the library. */
|
||||||
|
if (typeof callbackQueryId === 'object') {
|
||||||
|
/* eslint-disable no-param-reassign, prefer-rest-params */
|
||||||
|
deprecate('The method signature answerCallbackQuery([options]) has been deprecated since v0.29.0');
|
||||||
|
form = callbackQueryId;
|
||||||
|
/* eslint-enable no-param-reassign, prefer-rest-params */
|
||||||
|
} else {
|
||||||
|
form.callback_query_id = callbackQueryId;
|
||||||
|
}
|
||||||
return this._request('answerCallbackQuery', { form });
|
return this._request('answerCallbackQuery', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user