From 59b43a53552b7e04b855531f5422938f8a189c29 Mon Sep 17 00:00:00 2001 From: danielperez9430 Date: Mon, 28 Jul 2025 20:44:55 +0200 Subject: [PATCH] feat: Support Telegram Bot API v9.1 --- CHANGELOG.md | 43 ++--- doc/api.md | 407 ++++++++++++++++++++++++++++++++++++++++++++++-- src/telegram.js | 47 ++++++ 3 files changed, 464 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b7f82b..04ca798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,26 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [0.68.0][0.68.0] - UNRELEASE -1. Support Telegram Bot API 7.6 (@danielperez9430) - * sendPaidMedia +1. Support Telegram Bot API 9.1 (@danielperez9430) + * sendChecklist + * editMessageChecklist + * getMyStarBalance -2. Support Telegram Bot API 7.10 (@danielperez9430) - * Update: `purchased_paid_media` - -3. Support Telegram Bot API 8.0 and 8.1 - * savePreparedInlineMessage (@IsmailBinMujeeb & @danielperez9430) - * setUserEmojiStatus (@danielperez9430) - * editUserStarSubscription (@danielperez9430) - * getAvailableGifts (@danielperez9430) - * sendGift (@danielperez9430) - -4. Support Telegram Bot API 8.2 and 8.3 (@danielperez9430) - * verifyUser - * verifyChat - * removeUserVerification - * removeChatVerification - -5. Support Telegram Bot API 9.0 (@danielperez9430) +2. Support Telegram Bot API 9.0 (@danielperez9430) * readBusinessMessage * deleteBusinessMessages * setBusinessAccountName @@ -44,6 +30,25 @@ This project adheres to [Semantic Versioning](http://semver.org/). * deleteStory * giftPremiumSubscription +3. Support Telegram Bot API 8.2 and 8.3 (@danielperez9430) + * verifyUser + * verifyChat + * removeUserVerification + * removeChatVerification + +4. Support Telegram Bot API 8.0 and 8.1 + * savePreparedInlineMessage (@IsmailBinMujeeb & @danielperez9430) + * setUserEmojiStatus (@danielperez9430) + * editUserStarSubscription (@danielperez9430) + * getAvailableGifts (@danielperez9430) + * sendGift (@danielperez9430) + +5. Support Telegram Bot API 7.10 (@danielperez9430) + * Update: `purchased_paid_media` + +6. Support Telegram Bot API 7.6 (@danielperez9430) + * sendPaidMedia + ## [0.67.0][0.67.0] - 2024-05-30 1. Support Telegram Bot API 7.4 (@danielperez9430) diff --git a/doc/api.md b/doc/api.md index 1424e36..1f530d4 100644 --- a/doc/api.md +++ b/doc/api.md @@ -58,6 +58,7 @@ TelegramBot * [.sendVenue(chatId, latitude, longitude, title, address, [options])](#TelegramBot+sendVenue) ⇒ Promise * [.sendContact(chatId, phoneNumber, firstName, [options])](#TelegramBot+sendContact) ⇒ Promise * [.sendPoll(chatId, question, pollOptions, [options])](#TelegramBot+sendPoll) ⇒ Promise + * [.sendChecklist(businessConnectionId, chatId, checklist, [options])](#TelegramBot+sendChecklist) ⇒ Promise * [.sendDice(chatId, [options])](#TelegramBot+sendDice) ⇒ Promise * [.sendChatAction(chatId, action, [options])](#TelegramBot+sendChatAction) ⇒ Promise * [.setMessageReaction(chatId, messageId, [options])](#TelegramBot+setMessageReaction) ⇒ [ 'Promise' ].<Boolean> @@ -127,6 +128,7 @@ TelegramBot * [.editMessageText(text, [options])](#TelegramBot+editMessageText) ⇒ Promise * [.editMessageCaption(caption, [options])](#TelegramBot+editMessageCaption) ⇒ Promise * [.editMessageMedia(media, [options])](#TelegramBot+editMessageMedia) ⇒ Promise + * [.editMessageChecklist(businessConnectionId, chatId, messageId, checklist, [options])](#TelegramBot+editMessageChecklist) ⇒ Promise * [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ Promise * [.stopPoll(chatId, pollId, [options])](#TelegramBot+stopPoll) ⇒ Promise * [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ Promise @@ -151,6 +153,7 @@ TelegramBot * [.createInvoiceLink(title, description, payload, providerToken, currency, prices, [options])](#TelegramBot+createInvoiceLink) ⇒ Promise * [.answerShippingQuery(shippingQueryId, ok, [options])](#TelegramBot+answerShippingQuery) ⇒ Promise * [.answerPreCheckoutQuery(preCheckoutQueryId, ok, [options])](#TelegramBot+answerPreCheckoutQuery) ⇒ Promise + * [.getMyStarBalance([options])](#TelegramBot+getMyStarBalance) ⇒ Promise * [.getStarTransactions([options])](#TelegramBot+getStarTransactions) ⇒ Promise * [.refundStarPayment(userId, telegramPaymentChargeId, [options])](#TelegramBot+refundStarPayment) ⇒ Promise * [.editUserStarSubscription(userId, telegramPaymentChargeId, isCanceled, [options])](#TelegramBot+editUserStarSubscription) ⇒ Promise @@ -161,10 +164,28 @@ TelegramBot * [.deleteMessages(chatId, messageIds, [options])](#TelegramBot+deleteMessages) ⇒ [ 'Promise' ].<Boolean> * [.getAvailableGifts([options])](#TelegramBot+getAvailableGifts) ⇒ Promise * [.sendGift(giftId, [options])](#TelegramBot+sendGift) ⇒ Promise - * [.verifyUser(userId)](#TelegramBot+verifyUser) ⇒ Promise - * [.verifyChat(chatId)](#TelegramBot+verifyChat) ⇒ Promise - * [.removeUserVerification(userId)](#TelegramBot+removeUserVerification) ⇒ Promise - * [.removeChatVerification(chatId)](#TelegramBot+removeChatVerification) ⇒ Promise + * [.giftPremiumSubscription(userId, monthCount, starCount, [options])](#TelegramBot+giftPremiumSubscription) ⇒ Promise + * [.verifyUser(userId, [options])](#TelegramBot+verifyUser) ⇒ Promise + * [.verifyChat(chatId, [options])](#TelegramBot+verifyChat) ⇒ Promise + * [.removeUserVerification(userId, [options])](#TelegramBot+removeUserVerification) ⇒ Promise + * [.removeChatVerification(chatId, [options])](#TelegramBot+removeChatVerification) ⇒ Promise + * [.readBusinessMessage(businessConnectionId, chatId, messageId, [options])](#TelegramBot+readBusinessMessage) ⇒ Promise + * [.deleteBusinessMessages(businessConnectionId, messageIds, [options])](#TelegramBot+deleteBusinessMessages) ⇒ Promise + * [.setBusinessAccountName(businessConnectionId, firstName, [options])](#TelegramBot+setBusinessAccountName) ⇒ Promise + * [.setBusinessAccountUsername(businessConnectionId, [options])](#TelegramBot+setBusinessAccountUsername) ⇒ Promise + * [.setBusinessAccountBio(businessConnectionId, [options])](#TelegramBot+setBusinessAccountBio) ⇒ Promise + * [.setBusinessAccountProfilePhoto(businessConnectionId, photo, [options])](#TelegramBot+setBusinessAccountProfilePhoto) ⇒ Promise + * [.removeBusinessAccountProfilePhoto(businessConnectionId, [options])](#TelegramBot+removeBusinessAccountProfilePhoto) ⇒ Promise + * [.setBusinessAccountGiftSettings(businessConnectionId, showGiftButton, acceptedGiftTypes, [options])](#TelegramBot+setBusinessAccountGiftSettings) ⇒ Promise + * [.getBusinessAccountStarBalance(businessConnectionId, [options])](#TelegramBot+getBusinessAccountStarBalance) ⇒ Promise + * [.transferBusinessAccountStars(businessConnectionId, starCount, [options])](#TelegramBot+transferBusinessAccountStars) ⇒ Promise + * [.getBusinessAccountGifts(businessConnectionId, [options])](#TelegramBot+getBusinessAccountGifts) ⇒ Promise + * [.convertGiftToStars(businessConnectionId, ownedGiftId, [options])](#TelegramBot+convertGiftToStars) ⇒ Promise + * [.upgradeGift(businessConnectionId, ownedGiftId, [options])](#TelegramBot+upgradeGift) ⇒ Promise + * [.transferGift(businessConnectionId, ownedGiftId, newOwnerChatId, [options])](#TelegramBot+transferGift) ⇒ Promise + * [.postStory(businessConnectionId, content, activePeriod, [options])](#TelegramBot+postStory) ⇒ Promise + * [.editStory(businessConnectionId, storyId, content, [options])](#TelegramBot+editStory) ⇒ Promise + * [.deleteStory(businessConnectionId, storyId, [options])](#TelegramBot+deleteStory) ⇒ Promise * _static_ * [.errors](#TelegramBot.errors) : Object * [.messageTypes](#TelegramBot.messageTypes) : [ 'Array' ].<String> @@ -778,7 +799,7 @@ Use this method to send paid media. | --- | --- | --- | | chatId | Number \| String | Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) | | starCount | Number | The number of Telegram Stars that must be paid to buy access to the media; 1-10000 | -| media | String \| stream.Stream \| Buffer | A file path or Stream. | +| media | Array | Array of [InputPaidMedia](https://core.telegram.org/bots/api#inputpaidmedia). The media property can bea String, Stream or Buffer. | | [options] | Object | Additional Telegram query options | @@ -914,6 +935,23 @@ Use this method to send a native poll. | pollOptions | Array | Poll options, between 2-10 options (only 1-100 characters each) | | [options] | Object | Additional Telegram query options | + + +### telegramBot.sendChecklist(businessConnectionId, chatId, checklist, [options]) ⇒ Promise +Send sendChecklist. +Use this method to send a checklist on behalf of a connected business account. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned +**See**: https://core.telegram.org/bots/api#sendchecklist + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | Number \| String | Unique identifier for the business connection | +| chatId | Number \| String | Unique identifier for the group/channel | +| checklist | Object | A JSON-serialized object for the checklist to send | +| [options] | Object | Additional Telegram query options | + ### telegramBot.sendDice(chatId, [options]) ⇒ Promise @@ -2035,6 +2073,23 @@ Note: You **must provide one of chat_id, message_id, or inline_message_id** in y | media | Object | A JSON-serialized object for a new media content of the message | | [options] | Object | Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) | + + +### telegramBot.editMessageChecklist(businessConnectionId, chatId, messageId, checklist, [options]) ⇒ Promise +Use this method to edit a checklist on behalf of a business connection. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned. +**See**: https://core.telegram.org/bots/api#editmessagechecklist + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | Number \| String | Unique identifier for the target business connection | +| chatId | Number \| String | Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) | +| messageId | Number | Unique identifier for the target message | +| checklist | Object | A JSON-serialized object for the new checklist | +| [options] | Object | Additional Telegram query options | + ### telegramBot.editMessageReplyMarkup(replyMarkup, [options]) ⇒ Promise @@ -2459,6 +2514,19 @@ an [Update](https://core.telegram.org/bots/api#update) with the field *pre_check | ok | Boolean | Specify if every order details are ok | | [options] | Object | Additional Telegram query options | + + +### telegramBot.getMyStarBalance([options]) ⇒ Promise +Use this method to get the current Telegram Stars balance of the bot. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns a [StarAmount](https://core.telegram.org/bots/api#staramount) object +**See**: https://core.telegram.org/bots/api#getmystarbalance + +| Param | Type | Description | +| --- | --- | --- | +| [options] | Object | Additional Telegram query options | + ### telegramBot.getStarTransactions([options]) ⇒ Promise @@ -2597,7 +2665,7 @@ Use this method to returns the list of gifts that can be sent by the bot to user | Param | Type | Description | | --- | --- | --- | -| [options] | Object | Additional Telegram query options | +| [options] | Object | Additional Telegram query options. | @@ -2611,11 +2679,27 @@ Use this method to sends a gift to the given user or channel chat. | Param | Type | Description | | --- | --- | --- | | giftId | String | Unique identifier of the gift | -| [options] | Object | Additional Telegram query options | +| [options] | Object | Additional Telegram query options. | + + + +### telegramBot.giftPremiumSubscription(userId, monthCount, starCount, [options]) ⇒ Promise +Use this method to sends a gift to the given user or channel chat. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#getavailablegifts + +| Param | Type | Description | +| --- | --- | --- | +| userId | Number | Unique identifier of the target user who will receive a Telegram Premium subscription. | +| monthCount | Number | Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12. | +| starCount | String | Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months. | +| [options] | Object | Additional Telegram query options. | -### telegramBot.verifyUser(userId) ⇒ Promise +### telegramBot.verifyUser(userId, [options]) ⇒ Promise This method verifies a user [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. **Kind**: instance method of [TelegramBot](#TelegramBot) @@ -2624,11 +2708,12 @@ This method verifies a user [on behalf of the organization](https://telegram.org | Param | Type | Description | | --- | --- | --- | -| userId | Number | Unique identifier of the target user | +| userId | Number | Unique identifier of the target user. | +| [options] | Object | Additional Telegram query options. | -### telegramBot.verifyChat(chatId) ⇒ Promise +### telegramBot.verifyChat(chatId, [options]) ⇒ Promise This method verifies a chat [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. **Kind**: instance method of [TelegramBot](#TelegramBot) @@ -2637,11 +2722,12 @@ This method verifies a chat [on behalf of the organization](https://telegram.org | Param | Type | Description | | --- | --- | --- | -| chatId | Number | Unique identifier of the target chat | +| chatId | Number | Unique identifier of the target chat. | +| [options] | Object | Additional Telegram query options. | -### telegramBot.removeUserVerification(userId) ⇒ Promise +### telegramBot.removeUserVerification(userId, [options]) ⇒ Promise This method removes verification from a user who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. **Kind**: instance method of [TelegramBot](#TelegramBot) @@ -2651,10 +2737,11 @@ This method removes verification from a user who is currently verified [on behal | Param | Type | Description | | --- | --- | --- | | userId | Number | Unique identifier of the target user | +| [options] | Object | Additional Telegram query options | -### telegramBot.removeChatVerification(chatId) ⇒ Promise +### telegramBot.removeChatVerification(chatId, [options]) ⇒ Promise This method removes verification from a chat who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. **Kind**: instance method of [TelegramBot](#TelegramBot) @@ -2663,7 +2750,299 @@ This method removes verification from a chat who is currently verified [on behal | Param | Type | Description | | --- | --- | --- | -| chatId | Number | Unique identifier of the target chat | +| chatId | Number | Unique identifier of the target chat. | +| [options] | Object | Additional Telegram query options. | + + + +### telegramBot.readBusinessMessage(businessConnectionId, chatId, messageId, [options]) ⇒ Promise +This method marks incoming message as read on behalf of a business account. + +Requires the **can_read_messages** business bot right + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#readbusinessmessage + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection on behalf of which to read the message. | +| chatId | Number | Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours. | +| messageId | Number | Unique identifier of the message to mark as read. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.deleteBusinessMessages(businessConnectionId, messageIds, [options]) ⇒ Promise +This method delete messages on behalf of a business account. + +Requires the **can_delete_outgoing_messages** business bot right to delete messages sent by the bot itself, or the **can_delete_all_messages business** bot right to delete any message. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#deletebusinessmessages + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection on behalf of which to delete the message. | +| messageIds | [ 'Array' ].<Number> | List of 1-100 identifiers of messages to delete. All messages **must be from the same chat**. | +| [options] | Object | Additional Telegram query options. | + + + +### telegramBot.setBusinessAccountName(businessConnectionId, firstName, [options]) ⇒ Promise +This method changes the first and last name of a managed business account. + +Requires the **can_change_name** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#setbusinessaccountname + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| firstName | String | The new value of the first name for the business account; 1-64 characters. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.setBusinessAccountUsername(businessConnectionId, [options]) ⇒ Promise +This method changes the username of a managed business account. + +Requires the **can_change_username** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#setbusinessaccountusername + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.setBusinessAccountBio(businessConnectionId, [options]) ⇒ Promise +This method changes the bio of a managed business account. + +Requires the **can_change_bio** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#setbusinessaccountbio + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.setBusinessAccountProfilePhoto(businessConnectionId, photo, [options]) ⇒ Promise +This method changes the profile photo of a managed business account. + +Requires the **can_edit_profile_photo** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#setbusinessaccountprofilephoto + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| photo | String \| stream.Stream \| Buffer | New profile photo. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.removeBusinessAccountProfilePhoto(businessConnectionId, [options]) ⇒ Promise +This method removes the current profile photo of a managed business account. + +Requires the **can_edit_profile_photo** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#removebusinessaccountprofilephoto + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.setBusinessAccountGiftSettings(businessConnectionId, showGiftButton, acceptedGiftTypes, [options]) ⇒ Promise +This method changes the privacy settings pertaining to incoming gifts in a managed business account. + +Requires the **can_change_gift_settings** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#setbusinessaccountgiftsettings + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| showGiftButton | Boolean | Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field. | +| acceptedGiftTypes | Object | Types of gifts accepted by the business account. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.getBusinessAccountStarBalance(businessConnectionId, [options]) ⇒ Promise +This method returns the amount of Telegram Stars owned by a managed business account. + +Requires the **can_view_gifts_and_stars** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns [StarAmount](https://core.telegram.org/bots/api#staramount). +**See**: https://core.telegram.org/bots/api#getbusinessaccountstarbalance + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.transferBusinessAccountStars(businessConnectionId, starCount, [options]) ⇒ Promise +This method transfers Telegram Stars from the business account balance to the bot's balance. + +Requires the **can_transfer_stars** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns True. +**See**: https://core.telegram.org/bots/api#transferbusinessaccountstars + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| starCount | Number | Number of Telegram Stars to transfer; 1-10000. | +| [options] | Object | Additional Telegram query options. | + + + +### telegramBot.getBusinessAccountGifts(businessConnectionId, [options]) ⇒ Promise +This method returns the gifts received and owned by a managed business account. + +Requires the **can_view_gifts_and_stars** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns [OwnedGifts](https://core.telegram.org/bots/api#ownedgifts). +**See**: https://core.telegram.org/bots/api#getbusinessaccountgifts + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.convertGiftToStars(businessConnectionId, ownedGiftId, [options]) ⇒ Promise +This method converts a given regular gift to Telegram Stars. + +Requires the **can_convert_gifts_to_stars** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns True. +**See**: https://core.telegram.org/bots/api#convertgifttostars + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| ownedGiftId | String | Unique identifier of the regular gift that should be converted to Telegram Stars. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.upgradeGift(businessConnectionId, ownedGiftId, [options]) ⇒ Promise +This method upgrades a given regular gift to a unique gift. + +Requires the **can_transfer_and_upgrade_gifts** business bot right. +Additionally requires the **can_transfer_stars** business bot right **if the upgrade is paid**. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns True. +**See**: https://core.telegram.org/bots/api#upgradegift + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| ownedGiftId | String | Unique identifier of the regular gift that should be upgraded to a unique one. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.transferGift(businessConnectionId, ownedGiftId, newOwnerChatId, [options]) ⇒ Promise +This method transfers an owned unique gift to another user. + +Requires the **can_transfer_and_upgrade_gifts** business bot right. +Additionally requires the **can_transfer_stars** business bot right **if the transfer is paid**. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns True. +**See**: https://core.telegram.org/bots/api#transfergift + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| ownedGiftId | String | Unique identifier of the regular gift that should be transferred. | +| newOwnerChatId | Number | Unique identifier of the chat which will own the gift. The chat **must be active in the last 24 hours**. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.postStory(businessConnectionId, content, activePeriod, [options]) ⇒ Promise +This method posts a story on behalf of a managed business account. + +Requires the **can_manage_stories** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns [Story](https://core.telegram.org/bots/api#story). +**See**: https://core.telegram.org/bots/api#poststory + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| content | Array | [InputStoryContent](https://core.telegram.org/bots/api#inputpaidmedia). The photo/video property can be String, Stream or Buffer. | +| activePeriod | Number | Unique identifier of the chat which will own the gift. The chat **must be active in the last 24 hours**. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.editStory(businessConnectionId, storyId, content, [options]) ⇒ Promise +This method edits a story previously posted by the bot on behalf of a managed business account. + +Requires the **can_manage_stories** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns [Story](https://core.telegram.org/bots/api#story). +**See**: https://core.telegram.org/bots/api#editstory + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| storyId | Number | Unique identifier of the story to edit. | +| content | Array | [InputStoryContent](https://core.telegram.org/bots/api#inputpaidmedia). The photo/video property can be String, Stream or Buffer. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.deleteStory(businessConnectionId, storyId, [options]) ⇒ Promise +This method deletes a story previously posted by the bot on behalf of a managed business account. + +Requires the **can_manage_stories** business bot right. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns True. +**See**: https://core.telegram.org/bots/api#deletestory + +| Param | Type | Description | +| --- | --- | --- | +| businessConnectionId | String | Unique identifier of the business connection. | +| storyId | Number | Unique identifier of the story to delete. | +| [options] | Object | Additional Telegram query options. | diff --git a/src/telegram.js b/src/telegram.js index 4b22ed5..f2e41ef 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -1528,6 +1528,24 @@ class TelegramBot extends EventEmitter { return this._request('sendPoll', { form }); } + /** + * Send sendChecklist. + * Use this method to send a checklist on behalf of a connected business account. + * + * @param {Number|String} businessConnectionId Unique identifier for the business connection + * @param {Number|String} chatId Unique identifier for the group/channel + * @param {Object} checklist A JSON-serialized object for the checklist to send + * @param {Object} [options] Additional Telegram query options + * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned + * @see https://core.telegram.org/bots/api#sendchecklist + */ + sendChecklist(businessConnectionId, chatId, checklist, form = {}) { + form.business_connection_id = businessConnectionId; + form.chat_id = chatId; + form.checklist = stringify(checklist); + return this._request('sendChecklist', { form }); + } + /** * Send Dice * Use this method to send an animated emoji that will display a random value. @@ -2705,6 +2723,24 @@ class TelegramBot extends EventEmitter { return this._request('editMessageMedia', { form }); } + /** + * Use this method to edit a checklist on behalf of a business connection. + * @param {Number|String} businessConnectionId Unique identifier for the target business connection + * @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 for the target message + * @param {Object} checklist A JSON-serialized object for the new checklist + * @param {Object} [options] Additional Telegram query options + * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned. + * @see https://core.telegram.org/bots/api#editmessagechecklist + */ + editMessageChecklist(businessConnectionId, chatId, messageId, checklist, form = {}) { + form.business_connection_id = businessConnectionId; + form.chat_id = chatId; + form.message_id = messageId; + form.checklist = stringify(checklist); + return this._request('editMessageChecklist', { form }); + } + /** * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). * @@ -3209,6 +3245,17 @@ class TelegramBot extends EventEmitter { return this._request('answerPreCheckoutQuery', { form }); } + /** + * Use this method to get the current Telegram Stars balance of the bot. + * + * @param {Object} [options] Additional Telegram query options + * @return {Promise} On success, returns a [StarAmount](https://core.telegram.org/bots/api#staramount) object + * @see https://core.telegram.org/bots/api#getmystarbalance + */ + getMyStarBalance(form = {}) { + return this._request('getMyStarBalance', { form }); + } + /** * Use this method for get the bot's Telegram Star transactions in chronological order *