|
|
|
@ -22,7 +22,7 @@ class TelegramBot extends EventEmitter { |
|
|
|
'location', 'new_chat_participant', 'left_chat_participant', 'new_chat_title', |
|
|
|
'location', 'new_chat_participant', 'left_chat_participant', 'new_chat_title', |
|
|
|
'new_chat_photo', 'delete_chat_photo', 'group_chat_created' |
|
|
|
'new_chat_photo', 'delete_chat_photo', 'group_chat_created' |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Both request method to obtain messages are implemented. To use standard polling, set `polling: true` |
|
|
|
* Both request method to obtain messages are implemented. To use standard polling, set `polling: true` |
|
|
|
* on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a SSL certificate.
|
|
|
|
* on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a SSL certificate.
|
|
|
|
@ -454,6 +454,117 @@ class TelegramBot extends EventEmitter { |
|
|
|
return this._request('sendChatAction', { form }); |
|
|
|
return this._request('sendChatAction', { form }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Use this method to kick a user from a group or a supergroup. |
|
|
|
|
|
|
|
* In the case of supergroups, the user will not be able to return |
|
|
|
|
|
|
|
* to the group on their own using invite links, etc., unless unbanned |
|
|
|
|
|
|
|
* first. The bot must be an administrator in the group for this to work. |
|
|
|
|
|
|
|
* Returns True on success. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup |
|
|
|
|
|
|
|
* @param {String} userId Unique identifier of the target user |
|
|
|
|
|
|
|
* @return {Promise} |
|
|
|
|
|
|
|
* @see https://core.telegram.org/bots/api#kickchatmember
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
kickChatMember(chatId, userId) { |
|
|
|
|
|
|
|
const form = { |
|
|
|
|
|
|
|
chat_id: chatId, |
|
|
|
|
|
|
|
user_id: userId |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return this._request('kickChatMember', { form }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Use this method to unban a previously kicked user in a supergroup. |
|
|
|
|
|
|
|
* The user will not return to the group automatically, but will be |
|
|
|
|
|
|
|
* able to join via link, etc. The bot must be an administrator in |
|
|
|
|
|
|
|
* the group for this to work. Returns True on success. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup |
|
|
|
|
|
|
|
* @param {String} userId Unique identifier of the target user |
|
|
|
|
|
|
|
* @return {Promise} |
|
|
|
|
|
|
|
* @see https://core.telegram.org/bots/api#unbanchatmember
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
unbanChatMember(chatId, userId) { |
|
|
|
|
|
|
|
const form = { |
|
|
|
|
|
|
|
chat_id: chatId, |
|
|
|
|
|
|
|
user_id: userId |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return this._request('unbanChatMember', { form }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Use this method to send answers to callback queries sent from |
|
|
|
|
|
|
|
* inline keyboards. The answer will be displayed to the user as |
|
|
|
|
|
|
|
* a notification at the top of the chat screen or as an alert. |
|
|
|
|
|
|
|
* On success, True is returned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {Number|String} callbackQueryId Unique identifier for the query to be answered |
|
|
|
|
|
|
|
* @param {String} text Text of the notification. If not specified, nothing will be shown to the user |
|
|
|
|
|
|
|
* @param {Object} [options] Additional Telegram query options |
|
|
|
|
|
|
|
* @return {Promise} |
|
|
|
|
|
|
|
* @see https://core.telegram.org/bots/api#answercallbackquery
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
answerCallbackQuery(callbackQueryId, text, form = {}) { |
|
|
|
|
|
|
|
form.callback_query_id = callbackQueryId; |
|
|
|
|
|
|
|
form.text = text; |
|
|
|
|
|
|
|
return this._request('answerCallbackQuery', { form }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Use this method to edit text messages sent by the bot or via |
|
|
|
|
|
|
|
* the bot (for inline bots). On success, the edited Message is |
|
|
|
|
|
|
|
* returned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Note that you must provide one of chat_id, message_id, or |
|
|
|
|
|
|
|
* inline_message_id in your request. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {String} text New text of the message |
|
|
|
|
|
|
|
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) |
|
|
|
|
|
|
|
* @return {Promise} |
|
|
|
|
|
|
|
* @see https://core.telegram.org/bots/api#editmessagetext
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
editMessageText(text, form = {}) { |
|
|
|
|
|
|
|
form.text = text; |
|
|
|
|
|
|
|
return this._request('editMessageText', { form }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Use this method to edit captions of messages sent by the |
|
|
|
|
|
|
|
* bot or via the bot (for inline bots). On success, the |
|
|
|
|
|
|
|
* edited Message is returned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Note that you must provide one of chat_id, message_id, or |
|
|
|
|
|
|
|
* inline_message_id in your request. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {String} caption New caption of the message |
|
|
|
|
|
|
|
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) |
|
|
|
|
|
|
|
* @return {Promise} |
|
|
|
|
|
|
|
* @see https://core.telegram.org/bots/api#editmessagetext
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
editMessageCaption(caption, form = {}) { |
|
|
|
|
|
|
|
form.caption = caption; |
|
|
|
|
|
|
|
return this._request('editMessageCaption', { form }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Use this method to edit only the reply markup of messages |
|
|
|
|
|
|
|
* sent by the bot or via the bot (for inline bots). |
|
|
|
|
|
|
|
* On success, the edited Message is returned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Note that you must provide one of chat_id, message_id, or |
|
|
|
|
|
|
|
* inline_message_id in your request. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {Object} replyMarkup A JSON-serialized object for an inline keyboard. |
|
|
|
|
|
|
|
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) |
|
|
|
|
|
|
|
* @return {Promise} |
|
|
|
|
|
|
|
* @see https://core.telegram.org/bots/api#editmessagetext
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
editMessageReplyMarkup(replyMarkup, form = {}) { |
|
|
|
|
|
|
|
form.reply_markup = replyMarkup; |
|
|
|
|
|
|
|
return this._request('editMessageReplyMarkup', { form }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Use this method to get a list of profile pictures for a user. |
|
|
|
* Use this method to get a list of profile pictures for a user. |
|
|
|
* Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object.
|
|
|
|
* Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object.
|
|
|
|
|