Skip to content

Commit

Permalink
feat: Support Telegram Bot API 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperez9430 committed May 8, 2024
1 parent fea59f4 commit 65ef0a2
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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)
1. Support Telegram Bot API 7.2 & 7.3 (@danielperez9430)
* getBusinessConnection
* replaceStickerInSet

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.2-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![Bot API](https://img.shields.io/badge/Bot%20API-v.3-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
87 changes: 80 additions & 7 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TelegramBot
* [.close([options])](#TelegramBot+close) ⇒ <code>Promise</code>
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
* [.forwardMessage(chatId, fromChatId, messageId, [options])](#TelegramBot+forwardMessage) ⇒ <code>Promise</code>
* [.forwardMessages(chatId, fromChatId, messageIds, [options])](#TelegramBot+forwardMessages) ⇒ <code>Promise</code>
* [.copyMessage(chatId, fromChatId, messageId, [options])](#TelegramBot+copyMessage) ⇒ <code>Promise</code>
* [.copyMessages(chatId, fromChatId, messageIds, [options])](#TelegramBot+copyMessages) ⇒ <code>Promise</code>
* [.sendPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+sendPhoto) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -103,6 +104,8 @@ TelegramBot
* [.unhideGeneralForumTopic(chatId, [options])](#TelegramBot+unhideGeneralForumTopic) ⇒ <code>Promise</code>
* [.unpinAllGeneralForumTopicMessages(chatId, [options])](#TelegramBot+unpinAllGeneralForumTopicMessages) ⇒ <code>Promise</code>
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
* [.getUserChatBoosts(chatId, user_id, [options])](#TelegramBot+getUserChatBoosts) ⇒ <code>Promise</code>
* [.getBusinessConnection(businessConnectionId, [options])](#TelegramBot+getBusinessConnection) ⇒ <code>Promise</code>
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ <code>Promise</code>
Expand All @@ -129,6 +132,7 @@ TelegramBot
* [.addStickerToSet(userId, name, sticker, emojis, stickerType, [options], [fileOptions])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
* [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code>
* [.deleteStickerFromSet(sticker, [options])](#TelegramBot+deleteStickerFromSet) ⇒ <code>Promise</code>
* [.replaceStickerInSet(user_id, name, sticker, [options])](#TelegramBot+replaceStickerInSet) ⇒ <code>Promise</code>
* [.setStickerEmojiList(sticker, emojiList, [options])](#TelegramBot+setStickerEmojiList) ⇒ <code>Promise</code>
* [.setStickerKeywords(sticker, [options])](#TelegramBot+setStickerKeywords) ⇒ <code>Promise</code>
* [.setStickerMaskPosition(sticker, [options])](#TelegramBot+setStickerMaskPosition) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -547,6 +551,23 @@ Forward messages of any kind.
| messageId | <code>Number</code> \| <code>String</code> | Unique message identifier in the chat specified in fromChatId |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+forwardMessages"></a>

### telegramBot.forwardMessages(chatId, fromChatId, messageIds, [options]) ⇒ <code>Promise</code>
Use this method to forward multiple messages of any kind.
If some of the specified messages can't be found or forwarded, they are skipped.

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - An array of MessageId of the sent messages on success
**See**: https://core.telegram.org/bots/api#forwardmessages

| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) or username of the target channel (in the format `@channelusername`) |
| fromChatId | <code>Number</code> \| <code>String</code> | Unique identifier for the chat where the original message was sent (or channel username in the format `@channelusername`) |
| messageIds | <code>[ &#x27;Array&#x27; ].&lt;(Number\|String)&gt;</code> | Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+copyMessage"></a>

### telegramBot.copyMessage(chatId, fromChatId, messageId, [options]) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -691,7 +712,7 @@ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without s
### telegramBot.sendVoice(chatId, voice, [options], [fileOptions]) ⇒ <code>Promise</code>
Send voice

**Your audio must be in an .OGG file encoded with OPUS** (other formats may be sent as Audio or Document)
**Your audio must be in an .OGG file encoded with OPUS**, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document)

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
Expand Down Expand Up @@ -912,7 +933,7 @@ Use this method to change the chosen reactions on a message.

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code> - True on success
**See**: https://core.telegram.org/bots/api#setMessageReaction
**See**: https://core.telegram.org/bots/api#setmessagereaction

| Param | Type | Description |
| --- | --- | --- |
Expand Down Expand Up @@ -1344,7 +1365,7 @@ Use this method to get up to date information about the chat
username of a user, group or channel, etc.).

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - [Chat](https://core.telegram.org/bots/api#chat) object on success
**Returns**: <code>Promise</code> - [ChatFullInfo](https://core.telegram.org/bots/api#chatfullinfo) object on success
**See**: https://core.telegram.org/bots/api#getchat

| Param | Type | Description |
Expand Down Expand Up @@ -1657,6 +1678,36 @@ that are being deprecated.
| callbackQueryId | <code>String</code> | Unique identifier for the query to be answered |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+getUserChatBoosts"></a>

### telegramBot.getUserChatBoosts(chatId, user_id, [options]) ⇒ <code>Promise</code>
Use this method to get the list of boosts added to a chat by a use.
Requires administrator rights in the chat

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - On success, returns a [UserChatBoosts](https://core.telegram.org/bots/api#userchatboosts) object
**See**: https://core.telegram.org/bots/api#getuserchatboosts

| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the group/channel |
| user_id | <code>Number</code> | Unique identifier of the target user |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+getBusinessConnection"></a>

### telegramBot.getBusinessConnection(businessConnectionId, [options]) ⇒ <code>Promise</code>
Use this method to get information about the connection of the bot with a business account

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - On success, returns [BusinessConnection](https://core.telegram.org/bots/api#businessconnection) object
**See**: https://core.telegram.org/bots/api#getbusinessconnection

| Param | Type | Description |
| --- | --- | --- |
| businessConnectionId | <code>Number</code> \| <code>String</code> | Unique identifier for the group/channel |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+setMyCommands"></a>

### telegramBot.setMyCommands(commands, [options]) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -2013,9 +2064,11 @@ Use this method to add a new sticker to a set created by the bot.

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

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - True on success
Expand Down Expand Up @@ -2064,6 +2117,26 @@ Use this method to delete a sticker from a set created by the bot.
| sticker | <code>String</code> | File identifier of the sticker |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+replaceStickerInSet"></a>

### telegramBot.replaceStickerInSet(user_id, name, sticker, [options]) ⇒ <code>Promise</code>
Use this method to replace an existing sticker in a sticker set with a new one

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - True on success
**See**: https://core.telegram.org/bots/api#replacestickerinset
**Todo**

- [ ] Add tests for this method!


| Param | Type | Description |
| --- | --- | --- |
| user_id | <code>Number</code> | User identifier of the sticker set owner |
| name | <code>String</code> | Sticker set name |
| sticker | <code>String</code> | File identifier of the sticker |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+setStickerEmojiList"></a>

### telegramBot.setStickerEmojiList(sticker, emojiList, [options]) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -2366,7 +2439,7 @@ Use this method to delete multiple messages simultaneously. If some of the speci

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code> - True on success
**See**: https://core.telegram.org/bots/api#deleteMessages
**See**: https://core.telegram.org/bots/api#deletemessages

| Param | Type | Description |
| --- | --- | --- |
Expand Down
4 changes: 2 additions & 2 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ class TelegramBot extends EventEmitter {
/**
* Send voice
*
* **Your audio must be in an .OGG file encoded with OPUS** (other formats may be sent as Audio or Document)
* **Your audio must be in an .OGG file encoded with OPUS**, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document)
* @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
* @param {String|stream.Stream|Buffer} voice A file path, Stream or Buffer.
* Can also be a `file_id` previously uploaded.
Expand Down Expand Up @@ -1916,7 +1916,7 @@ class TelegramBot extends EventEmitter {
* username of a user, group or channel, etc.).
* @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) or channel
* @param {Object} [options] Additional Telegram query options
* @return {Promise} [Chat](https://core.telegram.org/bots/api#chat) object on success
* @return {Promise} [ChatFullInfo](https://core.telegram.org/bots/api#chatfullinfo) object on success
* @see https://core.telegram.org/bots/api#getchat
*/
getChat(chatId, form = {}) {
Expand Down

0 comments on commit 65ef0a2

Please sign in to comment.