Skip to content

Commit

Permalink
feat: Support Telegram Bot API 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperez9430 committed May 3, 2024
1 parent 556de87 commit fea59f4
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 23 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).


## [0.66.0][0.66.0] - 2024-05-03

1. Support Telegram Bot API 7.2 (@danielperez9430)
* getBusinessConnection
* replaceStickerInSet

2. Support for updates: (@danielperez9430)
* business_connection
* business_message
* edited_business_message
* deleted_business_messages

3. Minor fixes: (@danielperez9430)
* getUserChatBoosts

## [0.65.1][0.65.1] - 2024-03-09

1. Support for updates (@danielperez9430)
Expand Down Expand Up @@ -66,6 +81,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Fix add thumb in sendAudio, sendVideo and sendVideoNote
* Fix getMyCommands and setMyCommands
* Suggested tip amounts stringify in sendInvoice

## [0.60.0][0.60.0] - 2022-10-06

1. Support Telegram Bot API v6.3 (@danielperez9430)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).


[![Bot API](https://img.shields.io/badge/Bot%20API-v.7.1-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![Bot API](https://img.shields.io/badge/Bot%20API-v.7.2-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![npm package](https://img.shields.io/npm/v/node-telegram-bot-api?logo=npm&style=flat-square)](https://www.npmjs.org/package/node-telegram-bot-api)
[![Build Status](https://img.shields.io/travis/yagop/node-telegram-bot-api/master?style=flat-square&logo=travis)](https://travis-ci.org/yagop/node-telegram-bot-api)
[![Coverage Status](https://img.shields.io/codecov/c/github/yagop/node-telegram-bot-api?style=flat-square&logo=codecov)](https://codecov.io/gh/yagop/node-telegram-bot-api)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-telegram-bot-api",
"version": "0.65.1",
"version": "0.66.0",
"description": "Telegram Bot API",
"main": "./index.js",
"directories": {
Expand Down
90 changes: 69 additions & 21 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ class TelegramBot extends EventEmitter {
const editedMessage = update.edited_message;
const channelPost = update.channel_post;
const editedChannelPost = update.edited_channel_post;
const businessConnection = update.business_connection;
const businesssMessage = update.business_message;
const editedBusinessMessage = update.edited_business_message;
const deletedBusinessMessage = update.deleted_business_messages;
const messageReaction = update.message_reaction;
const messageReactionCount = update.message_reaction_count;
const inlineQuery = update.inline_query;
Expand Down Expand Up @@ -759,6 +763,18 @@ class TelegramBot extends EventEmitter {
if (editedChannelPost.caption) {
this.emit('edited_channel_post_caption', editedChannelPost);
}
} else if (businessConnection) {
debug('Process Update business_connection %j', businessConnection);
this.emit('business_connection', businessConnection);
} else if (businesssMessage) {
debug('Process Update business_message %j', businesssMessage);
this.emit('business_message', businesssMessage);
} else if (editedBusinessMessage) {
debug('Process Update edited_business_message %j', editedBusinessMessage);
this.emit('edited_business_message', editedBusinessMessage);
} else if (deletedBusinessMessage) {
debug('Process Update deleted_business_messages %j', deletedBusinessMessage);
this.emit('deleted_business_messages', deletedBusinessMessage);
} else if (messageReaction) {
debug('Process Update message_reaction %j', messageReaction);
this.emit('message_reaction', messageReaction);
Expand Down Expand Up @@ -2240,7 +2256,20 @@ class TelegramBot extends EventEmitter {
getUserChatBoosts(chatId, pollId, form = {}) {
form.chat_id = chatId;
form.message_id = pollId;
return this._request('stopPoll', { form });
return this._request('getUserChatBoosts', { form });
}

/**
* Use this method to get information about the connection of the bot with a business account
*
* @param {Number|String} businessConnectionId Unique identifier for the group/channel
* @param {Object} [options] Additional Telegram query options
* @return {Promise} On success, returns [BusinessConnection](https://core.telegram.org/bots/api#businessconnection) object
* @see https://core.telegram.org/bots/api#getbusinessconnection
*/
getBusinessConnection(businessConnectionId, form = {}) {
form.business_connection_id = businessConnectionId;
return this._request('getBusinessConnection', { form });
}

/**
Expand Down Expand Up @@ -2614,7 +2643,6 @@ class TelegramBot extends EventEmitter {
* @param {Number} userId User identifier of created sticker set owner
* @param {String} name Short name of sticker set, to be used in `t.me/addstickers/` URLs (e.g., *"animals"*). Can contain only english letters, digits and underscores.
* Must begin with a letter, can't contain consecutive underscores and must end in `"_by_<bot_username>"`. `<bot_username>` is case insensitive. 1-64 characters.
* @param {String} title Sticker set title, 1-64 characters
* @param {String|stream.Stream|Buffer} pngSticker Png image with the sticker, must be up to 512 kilobytes in size,
* dimensions must not exceed 512px, and either width or height must be exactly 512px.
Expand Down Expand Up @@ -2648,9 +2676,11 @@ class TelegramBot extends EventEmitter {
*
* You must use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*
*
* Animated stickers can be added to animated sticker sets and only to them:
* - Animated sticker sets can have up to 50 stickers.
* - Static sticker sets can have up to 120 stickers
* Animated stickers can be added to animated sticker sets and only to them
*
* Note:
* - Emoji sticker sets can have up to 200 sticker
* - Static or Animated sticker sets can have up to 120 stickers
*
* @param {Number} userId User identifier of sticker set owner
* @param {String} name Sticker set name
Expand Down Expand Up @@ -2716,6 +2746,24 @@ class TelegramBot extends EventEmitter {
return this._request('deleteStickerFromSet', { form });
}

/**
* Use this method to replace an existing sticker in a sticker set with a new one
*
* @param {Number} user_id User identifier of the sticker set owner
* @param {String} name Sticker set name
* @param {String} sticker File identifier of the sticker
* @param {Object} [options] Additional Telegram query options
* @return {Promise} True on success
* @see https://core.telegram.org/bots/api#replacestickerinset
* @todo Add tests for this method!
*/
replaceStickerInSet(userId, name, oldSticker, form = {}) {
form.user_id = userId;
form.name = name;
form.old_sticker = oldSticker;
return this._request('deleteStickerFromSet', { form });
}


/**
* Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
Expand Down Expand Up @@ -3023,22 +3071,22 @@ class TelegramBot extends EventEmitter {
}


/**
* Use this method to delete a message, including service messages, with the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - A dice message can only be deleted if it was sent more than 24 hours ago.
* - Bots can delete outgoing messages in groups and supergroups.
* - Bots can delete incoming messages in groups, supergroups and channels.
* - Bots granted `can_post_messages` permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has `can_delete_messages` permission in a supergroup, it can delete any message there.
*
* @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param {Number} messageId Unique identifier of the target message
* @param {Object} [options] Additional Telegram query options
* @return {Promise} True on success
* @see https://core.telegram.org/bots/api#deletemessage
*/
/**
* Use this method to delete a message, including service messages, with the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - A dice message can only be deleted if it was sent more than 24 hours ago.
* - Bots can delete outgoing messages in groups and supergroups.
* - Bots can delete incoming messages in groups, supergroups and channels.
* - Bots granted `can_post_messages` permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has `can_delete_messages` permission in a supergroup, it can delete any message there.
*
* @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param {Number} messageId Unique identifier of the target message
* @param {Object} [options] Additional Telegram query options
* @return {Promise} True on success
* @see https://core.telegram.org/bots/api#deletemessage
*/
deleteMessage(chatId, messageId, form = {}) {
form.chat_id = chatId;
form.message_id = messageId;
Expand Down

0 comments on commit fea59f4

Please sign in to comment.