Skip to content

Commit 542002e

Browse files
feat: Telegram Bot API Support 6.6 + 6.7 [WIP] (yagop#1069)
* feat: Telegram Bot API Support * refactor: uploadStickerFile * feat: Support Telegram Bot API v6.7 * fix: tests * feat: Test for deleteStickerSet
1 parent 2885db0 commit 542002e

File tree

4 files changed

+571
-36
lines changed

4 files changed

+571
-36
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.62.0][0.62.0] - 2023-03-19
7+
8+
1. Support Telegram Bot API v6.6 (@danielperez9430)
9+
* setMyDescription
10+
* getMyDescription
11+
* setMyShortDescription
12+
* getMyShortDescription
13+
* setCustomEmojiStickerSetThumbnail
14+
* setStickerSetTitle
15+
* deleteStickerSet
16+
* setStickerEmojiList
17+
* setStickerKeywords
18+
* setStickerMaskPosition
19+
620
## [0.61.0][0.61.0] - 2022-12-30
721

822
1. Support Telegram Bot API v6.4 (@danielperez9430)

doc/api.md

Lines changed: 206 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ TelegramBot
103103
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
104104
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
105105
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ <code>Promise</code>
106+
* [.setMyName([options])](#TelegramBot+setMyName) ⇒ <code>Promise</code>
107+
* [.getMyName([options])](#TelegramBot+getMyName) ⇒ <code>Promise</code>
108+
* [.setMyDescription([options])](#TelegramBot+setMyDescription) ⇒ <code>Promise</code>
109+
* [.getMyDescription([options])](#TelegramBot+getMyDescription) ⇒ <code>Promise</code>
110+
* [.setMyShortDescription([options])](#TelegramBot+setMyShortDescription) ⇒ <code>Promise</code>
111+
* [.getMyShortDescription([options])](#TelegramBot+getMyShortDescription) ⇒ <code>Promise</code>
106112
* [.setChatMenuButton([options])](#TelegramBot+setChatMenuButton) ⇒ <code>Promise</code>
107113
* [.getChatMenuButton([options])](#TelegramBot+getChatMenuButton) ⇒ <code>Promise</code>
108114
* [.setMyDefaultAdministratorRights([options])](#TelegramBot+setMyDefaultAdministratorRights) ⇒ <code>Promise</code>
@@ -116,12 +122,18 @@ TelegramBot
116122
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <code>Promise</code>
117123
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
118124
* [.getCustomEmojiStickers(custom_emoji_ids, [options])](#TelegramBot+getCustomEmojiStickers) ⇒ <code>Promise</code>
119-
* [.uploadStickerFile(userId, pngSticker, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
125+
* [.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
120126
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
121127
* [.addStickerToSet(userId, name, sticker, emojis, stickerType, [options], [fileOptions])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
122128
* [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code>
123129
* [.deleteStickerFromSet(sticker, [options])](#TelegramBot+deleteStickerFromSet) ⇒ <code>Promise</code>
124-
* [.setStickerSetThumb(userId, name, pngThumb, [options], [fileOptions])](#TelegramBot+setStickerSetThumb) ⇒ <code>Promise</code>
130+
* [.setStickerEmojiList(sticker, emojiList, [options])](#TelegramBot+setStickerEmojiList) ⇒ <code>Promise</code>
131+
* [.setStickerKeywords(sticker, [options])](#TelegramBot+setStickerKeywords) ⇒ <code>Promise</code>
132+
* [.setStickerMaskPosition(sticker, [options])](#TelegramBot+setStickerMaskPosition) ⇒ <code>Promise</code>
133+
* [.setStickerSetTitle(name, title, [options])](#TelegramBot+setStickerSetTitle) ⇒ <code>Promise</code>
134+
* [.setStickerSetThumbnail(userId, name, thumbnail, [options], [fileOptions])](#TelegramBot+setStickerSetThumbnail) ⇒ <code>Promise</code>
135+
* [.setCustomEmojiStickerSetThumbnail(name, [options])](#TelegramBot+setCustomEmojiStickerSetThumbnail) ⇒ <code>Promise</code>
136+
* [.deleteStickerSet(name, [options])](#TelegramBot+deleteStickerSet) ⇒ <code>Promise</code>
125137
* [.answerInlineQuery(inlineQueryId, results, [options])](#TelegramBot+answerInlineQuery) ⇒ <code>Promise</code>
126138
* [.answerWebAppQuery(webAppQueryId, result, [options])](#TelegramBot+answerWebAppQuery) ⇒ <code>Promise</code>
127139
* [.sendInvoice(chatId, title, description, payload, providerToken, currency, prices, [options])](#TelegramBot+sendInvoice) ⇒ <code>Promise</code>
@@ -1632,6 +1644,87 @@ Use this method to get the current list of the bot's commands for the given scop
16321644
| --- | --- | --- |
16331645
| [options] | <code>Object</code> | Additional Telegram query options |
16341646

1647+
<a name="TelegramBot+setMyName"></a>
1648+
1649+
### telegramBot.setMyName([options]) ⇒ <code>Promise</code>
1650+
Use this method to change the bot's name.
1651+
1652+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1653+
**Returns**: <code>Promise</code> - True on success
1654+
**See**: https://core.telegram.org/bots/api#setmyname
1655+
1656+
| Param | Type | Description |
1657+
| --- | --- | --- |
1658+
| [options] | <code>Object</code> | Additional Telegram query options |
1659+
1660+
<a name="TelegramBot+getMyName"></a>
1661+
1662+
### telegramBot.getMyName([options]) ⇒ <code>Promise</code>
1663+
Use this method to get the current bot name for the given user language.
1664+
1665+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1666+
**Returns**: <code>Promise</code> - [BotName](https://core.telegram.org/bots/api#botname) on success
1667+
**See**: https://core.telegram.org/bots/api#getmyname
1668+
1669+
| Param | Type | Description |
1670+
| --- | --- | --- |
1671+
| [options] | <code>Object</code> | Additional Telegram query options |
1672+
1673+
<a name="TelegramBot+setMyDescription"></a>
1674+
1675+
### telegramBot.setMyDescription([options]) ⇒ <code>Promise</code>
1676+
Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
1677+
1678+
Returns True on success.
1679+
1680+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1681+
**Returns**: <code>Promise</code> - True on success
1682+
**See**: https://core.telegram.org/bots/api#setmydescription
1683+
1684+
| Param | Type | Description |
1685+
| --- | --- | --- |
1686+
| [options] | <code>Object</code> | Additional Telegram query options |
1687+
1688+
<a name="TelegramBot+getMyDescription"></a>
1689+
1690+
### telegramBot.getMyDescription([options]) ⇒ <code>Promise</code>
1691+
Use this method to get the current bot description for the given user language.
1692+
1693+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1694+
**Returns**: <code>Promise</code> - Returns [BotDescription](https://core.telegram.org/bots/api#botdescription) on success.
1695+
**See**: https://core.telegram.org/bots/api#getmydescription
1696+
1697+
| Param | Type | Description |
1698+
| --- | --- | --- |
1699+
| [options] | <code>Object</code> | Additional Telegram query options |
1700+
1701+
<a name="TelegramBot+setMyShortDescription"></a>
1702+
1703+
### telegramBot.setMyShortDescription([options]) ⇒ <code>Promise</code>
1704+
Use this method to change the bot's short description, which is shown on the bot's profile page
1705+
and is sent together with the link when users share the bot.
1706+
1707+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1708+
**Returns**: <code>Promise</code> - Returns True on success.
1709+
**See**: https://core.telegram.org/bots/api#setmyshortdescription
1710+
1711+
| Param | Type | Description |
1712+
| --- | --- | --- |
1713+
| [options] | <code>Object</code> | Additional Telegram query options |
1714+
1715+
<a name="TelegramBot+getMyShortDescription"></a>
1716+
1717+
### telegramBot.getMyShortDescription([options]) ⇒ <code>Promise</code>
1718+
Use this method to get the current bot short description for the given user language.
1719+
1720+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1721+
**Returns**: <code>Promise</code> - Returns [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription) on success.
1722+
**See**: https://core.telegram.org/bots/api#getmyshortdescription
1723+
1724+
| Param | Type | Description |
1725+
| --- | --- | --- |
1726+
| [options] | <code>Object</code> | Additional Telegram query options |
1727+
16351728
<a name="TelegramBot+setChatMenuButton"></a>
16361729

16371730
### telegramBot.setChatMenuButton([options]) ⇒ <code>Promise</code>
@@ -1839,20 +1932,21 @@ Use this method to get information about custom emoji stickers by their identifi
18391932

18401933
<a name="TelegramBot+uploadStickerFile"></a>
18411934

1842-
### telegramBot.uploadStickerFile(userId, pngSticker, [options], [fileOptions]) ⇒ <code>Promise</code>
1843-
Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
1935+
### telegramBot.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions]) ⇒ <code>Promise</code>
1936+
Use this method to upload a file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
18441937
times).
18451938

18461939
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
18471940
**Returns**: <code>Promise</code> - On success, a [File](https://core.telegram.org/bots/api#file) object is returned
18481941
**See**: https://core.telegram.org/bots/api#uploadstickerfile
18491942

1850-
| Param | Type | Description |
1851-
| --- | --- | --- |
1852-
| userId | <code>Number</code> | User identifier of sticker file owner |
1853-
| pngSticker | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | A file path or a Stream. Can also be a `file_id` previously uploaded. **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. |
1854-
| [options] | <code>Object</code> | Additional Telegram query options |
1855-
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
1943+
| Param | Type | Default | Description |
1944+
| --- | --- | --- | --- |
1945+
| userId | <code>Number</code> | | User identifier of sticker file owner |
1946+
| sticker | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | | A file path or a Stream with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. Can also be a `file_id` previously uploaded. |
1947+
| stickerFormat | <code>String</code> | <code>static</code> | Allow values: `static`, `animated` or `video` |
1948+
| [options] | <code>Object</code> | | Additional Telegram query options |
1949+
| [fileOptions] | <code>Object</code> | | Optional file related meta-data |
18561950

18571951
<a name="TelegramBot+createNewStickerSet"></a>
18581952

@@ -1935,25 +2029,123 @@ Use this method to delete a sticker from a set created by the bot.
19352029
| sticker | <code>String</code> | File identifier of the sticker |
19362030
| [options] | <code>Object</code> | Additional Telegram query options |
19372031

1938-
<a name="TelegramBot+setStickerSetThumb"></a>
2032+
<a name="TelegramBot+setStickerEmojiList"></a>
2033+
2034+
### telegramBot.setStickerEmojiList(sticker, emojiList, [options]) ⇒ <code>Promise</code>
2035+
Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
2036+
2037+
The sticker must belong to a sticker set created by the bot.
2038+
2039+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
2040+
**Returns**: <code>Promise</code> - True on success
2041+
**See**: https://core.telegram.org/bots/api#setstickeremojilist
2042+
2043+
| Param | Type | Description |
2044+
| --- | --- | --- |
2045+
| sticker | <code>String</code> | File identifier of the sticker |
2046+
| emojiList | <code>Array</code> | A JSON-serialized list of 1-20 emoji associated with the sticker |
2047+
| [options] | <code>Object</code> | Additional Telegram query options |
2048+
2049+
<a name="TelegramBot+setStickerKeywords"></a>
2050+
2051+
### telegramBot.setStickerKeywords(sticker, [options]) ⇒ <code>Promise</code>
2052+
Use this method to change the list of emoji assigned to a `regular` or `custom emoji` sticker.
2053+
2054+
The sticker must belong to a sticker set created by the bot.
2055+
2056+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
2057+
**Returns**: <code>Promise</code> - True on success
2058+
**See**: https://core.telegram.org/bots/api#setstickerkeywords
2059+
2060+
| Param | Type | Description |
2061+
| --- | --- | --- |
2062+
| sticker | <code>String</code> | File identifier of the sticker |
2063+
| [options] | <code>Object</code> | Additional Telegram query options |
2064+
2065+
<a name="TelegramBot+setStickerMaskPosition"></a>
2066+
2067+
### telegramBot.setStickerMaskPosition(sticker, [options]) ⇒ <code>Promise</code>
2068+
Use this method to change the [mask position](https://core.telegram.org/bots/api#maskposition) of a mask sticker.
2069+
2070+
The sticker must belong to a sticker set created by the bot.
2071+
2072+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
2073+
**Returns**: <code>Promise</code> - True on success
2074+
**See**: https://core.telegram.org/bots/api#setstickermaskposition
2075+
2076+
| Param | Type | Description |
2077+
| --- | --- | --- |
2078+
| sticker | <code>String</code> | File identifier of the sticker |
2079+
| [options] | <code>Object</code> | Additional Telegram query options |
2080+
2081+
<a name="TelegramBot+setStickerSetTitle"></a>
2082+
2083+
### telegramBot.setStickerSetTitle(name, title, [options]) ⇒ <code>Promise</code>
2084+
Use this method to set the title of a created sticker set.
19392085

1940-
### telegramBot.setStickerSetThumb(userId, name, pngThumb, [options], [fileOptions]) ⇒ <code>Promise</code>
2086+
The sticker must belong to a sticker set created by the bot.
2087+
2088+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
2089+
**Returns**: <code>Promise</code> - True on success
2090+
**See**: https://core.telegram.org/bots/api#setstickersettitle
2091+
2092+
| Param | Type | Description |
2093+
| --- | --- | --- |
2094+
| name | <code>String</code> | Sticker set name |
2095+
| title | <code>String</code> | Sticker set title, 1-64 characters |
2096+
| [options] | <code>Object</code> | Additional Telegram query options |
2097+
2098+
<a name="TelegramBot+setStickerSetThumbnail"></a>
2099+
2100+
### telegramBot.setStickerSetThumbnail(userId, name, thumbnail, [options], [fileOptions]) ⇒ <code>Promise</code>
19412101
Use this method to add a thumb to a set created by the bot.
19422102

19432103
Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only
19442104

19452105
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
19462106
**Returns**: <code>Promise</code> - True on success
1947-
**See**: https://core.telegram.org/bots/api#setstickersetthumb
2107+
**See**: https://core.telegram.org/bots/api#setstickersetthumbnail
19482108

19492109
| Param | Type | Description |
19502110
| --- | --- | --- |
19512111
| userId | <code>Number</code> | User identifier of sticker set owner |
19522112
| name | <code>String</code> | Sticker set name |
1953-
| pngThumb | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, a TGS animation with the thumbnail up to 32 kilobytes in size or a WEBM video with the thumbnail up to 32 kilobytes in size. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one. Animated sticker set thumbnails can't be uploaded via HTTP URL. |
2113+
| thumbnail | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, a TGS animation with the thumbnail up to 32 kilobytes in size or a WEBM video with the thumbnail up to 32 kilobytes in size. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one. Animated sticker set thumbnails can't be uploaded via HTTP URL. |
19542114
| [options] | <code>Object</code> | Additional Telegram query options |
19552115
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
19562116

2117+
<a name="TelegramBot+setCustomEmojiStickerSetThumbnail"></a>
2118+
2119+
### telegramBot.setCustomEmojiStickerSetThumbnail(name, [options]) ⇒ <code>Promise</code>
2120+
Use this method to set the thumbnail of a custom emoji sticker set.
2121+
2122+
The sticker must belong to a sticker set created by the bot.
2123+
2124+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
2125+
**Returns**: <code>Promise</code> - True on success
2126+
**See**: https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail
2127+
2128+
| Param | Type | Description |
2129+
| --- | --- | --- |
2130+
| name | <code>String</code> | Sticker set name |
2131+
| [options] | <code>Object</code> | Additional Telegram query options |
2132+
2133+
<a name="TelegramBot+deleteStickerSet"></a>
2134+
2135+
### telegramBot.deleteStickerSet(name, [options]) ⇒ <code>Promise</code>
2136+
Use this method to delete a sticker set that was created by the bot.
2137+
2138+
The sticker must belong to a sticker set created by the bot.
2139+
2140+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
2141+
**Returns**: <code>Promise</code> - True on success
2142+
**See**: https://core.telegram.org/bots/api#deletestickerset
2143+
2144+
| Param | Type | Description |
2145+
| --- | --- | --- |
2146+
| name | <code>String</code> | Sticker set name |
2147+
| [options] | <code>Object</code> | Additional Telegram query options |
2148+
19572149
<a name="TelegramBot+answerInlineQuery"></a>
19582150

19592151
### telegramBot.answerInlineQuery(inlineQueryId, results, [options]) ⇒ <code>Promise</code>

0 commit comments

Comments
 (0)