2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-22 18:07:16 +00:00

Bot API 5.1: Support Improved Invite Links and new messageTypes (#859)

* Add new method sendPoll

* getMyCommands

* setMyCommands

* Update doc/api

* 1# Fix Test sendPhoto

The sendPhoto method does not support .gif files, use sendAnimation.

This fix remplace .gif file by .png

* CustomTitle and ChatPermissions support

setChatAdministratorCustomTitle
setChatPermissions

* Update Readme

Update Badge Telegram API Version

* Minor Fix and Fix setChatPhoto

The Telegram Bots api has a bug that they are fixing and gives problems with the previous image. While they don't fix it, the image replacement is the fastest solution

* Minor Fix and Add Test

Fixed setChatPermissions

Test:
- sendDice
- getMyCommands
- setMyCommands
- setChatAdministratorCustomTitle
- setChatPermissions

* Update Changelog and Package.json version

* Fix typos in Changelog

* Add support for poll_answer

From: https://github.com/yagop/node-telegram-bot-api/pull/777

* Add JieJiSS contribution in Changelog

* Add sendPoll Test

* Add unpinAllChatMessages Support

* Add copyMessage support

* Add close and logOut Support

* Add Test + Minor fixes

* Update CHANGELOG

Update version 0.50.1

* Update Readme Bot API Badge

* Update Version to 0.51.0

* Bot API 5.1 support Improved Invite Links

- Added the method createChatInviteLink
- Added the method editChatInviteLink
- Added the method revokeChatInviteLink

* Update version to 0.52.0 and new tests

- Update Changelog
- New Test
- Update version to 0.52.0

* Add new messageTypes

-  voice_chat_started
-  voice_chat_ended
- voice_chat_participants_invited

* Update Changelog and add new MessageType

* New messageTypes and updates

Add support for new messageTypes:
  - chat_invite_link
  - chat_member_updated

Add support for new updates:
 - my_chat_member
 - chat_member
This commit is contained in:
Daniel Pérez Fernández 2021-03-29 16:37:10 +02:00 committed by GitHub
parent 28cd62e355
commit de76dcd2cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 563 additions and 552 deletions

View File

@ -3,24 +3,52 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## [0.52.0][0.52.0] - 2021-03-20
Added:
1. Support Bot API v5.1: (by @danielperez9430)
* Add method *createChatInviteLink()*
* Add method *editChatInviteLink()*
* Add method *revokeChatInviteLink()*
* Add support for new messageTypes:
* *voice_chat_started*
* *voice_chat_ended*
* *voice_chat_participants_invited*
* *message_auto_delete_timer_changed*
* *chat_invite_link*
* *chat_member_updated*
* Add support for new updates:
* *my_chat_member*
* *chat_member*
New Test: (by @danielperez9430)
* createChatInviteLink
* editChatInviteLink
* revokeChatInviteLink
## [0.51.0][0.51.0] - 2020-11-04 ## [0.51.0][0.51.0] - 2020-11-04
Added: Added:
1. Support Bot API v5.0: (by @danielperez9430) 1. Support Bot API v5.0: (by @danielperez9430)
* Add method *copyMessage()*
* Add method *unpinAllChatMessages()* * Add method *copyMessage()*
* Add method *close()* * Add method *unpinAllChatMessages()*
* Add method *logOut()* * Add method *close()*
* Add method *logOut()*
Changed: (by @danielperez9430)
* Remove trailing-spaces Changed: (by @danielperez9430)
* Fix Bugs in Test
* Remove trailing-spaces
New Test: (by @danielperez9430) * Fix Bugs in Test
* copyMessage
* unpinAllChatMessages New Test: (by @danielperez9430)
* copyMessage
* unpinAllChatMessages
## [0.50.0][0.50.0] - 2020-05-2020 ## [0.50.0][0.50.0] - 2020-05-2020
@ -28,27 +56,29 @@ Added:
1. Support Bot API v4.8: (by @danielperez9430) 1. Support Bot API v4.8: (by @danielperez9430)
* Add methods: *sendDice()* * Add methods: *sendDice()*
1. Support Bot API v4.7: (by @danielperez9430) 2. Support Bot API v4.7: (by @danielperez9430)
* Add methods: *getMyCommands()*,*setMyCommands()* * Add methods: *getMyCommands()*,*setMyCommands()*
1. Support Bot API v4.5: (by @danielperez9430) 3. Support Bot API v4.5: (by @danielperez9430)
* Add methods: *setChatAdministratorCustomTitle()* * Add methods: *setChatAdministratorCustomTitle()*
1. Support Bot API v4.4: (by @danielperez9430) 4. Support Bot API v4.4: (by @danielperez9430)
* Add methods: *setChatPermissions()* * Add methods: *setChatPermissions()*
1. Support for poll_answer (by @JieJiSS) 5. Support for poll_answer (by @JieJiSS)
1. Add request options in file stream (by @zhangpanyi ) 6. Add request options in file stream (by @zhangpanyi )
Changed: (by @danielperez9430) Changed: (by @danielperez9430)
* New message type: *dice*
* Fix Bugs in tests * New message type: *dice*
* Fix regex compare (by @ledamint) * Fix Bugs in tests
* Fix listening for error events when downloading files (by @Kraigo) * Fix regex compare (by @ledamint)
* Fix listening for error events when downloading files (by @Kraigo)
New Test: (by @danielperez9430) New Test: (by @danielperez9430)
* sendDice
* getMyCommands * sendDice
* setMyCommands * getMyCommands
* setChatAdministratorCustomTitle * setMyCommands
* setChatPermissions * setChatAdministratorCustomTitle
* setChatPermissions
## [0.40.0][0.40.0] - 2019-05-04 ## [0.40.0][0.40.0] - 2019-05-04
@ -57,11 +87,10 @@ Added:
1. Support Bot API v4.2: (by @kamikazechaser) 1. Support Bot API v4.2: (by @kamikazechaser)
* Add methods: *TelegramBot#sendPoll()*, *TelegramBot#stopPoll()* * Add methods: *TelegramBot#sendPoll()*, *TelegramBot#stopPoll()*
* Support events: *poll* * Support events: *poll*
1. Support Bot API v4.0: (by @kamikazechaser) 2. Support Bot API v4.0: (by @kamikazechaser)
* Add methods: *TelegramBot#editMessageMedia()*, *TelegramBot#sendAnimation()* * Add methods: *TelegramBot#editMessageMedia()*, *TelegramBot#sendAnimation()*
* Support new message types: *passport_data*, *animation* * Support new message types: *passport_data*, *animation*
* * * * * *
## [0.30.0][0.30.0] - 2017-12-21 ## [0.30.0][0.30.0] - 2017-12-21
@ -69,37 +98,36 @@ Added:
Added: Added:
1. Support Bot API v3.5: (by @GochoMugo) 1. Support Bot API v3.5: (by @GochoMugo)
* Allow `provider_data` parameter in *TelegramBot#sendInvoice* * Allow `provider_data` parameter in *TelegramBot#sendInvoice*
* Add method *TelegramBot#sendMediaGroup()* * Add method *TelegramBot#sendMediaGroup()*
1. Support Bot API v3.4: (by @kamikazechaser) 2. Support Bot API v3.4: (by @kamikazechaser)
* Add methods *TelegramBot#editMessageLiveLocation*, *TelegramBot#stopMessageLiveLocation* (#439) * Add methods *TelegramBot#editMessageLiveLocation*, *TelegramBot#stopMessageLiveLocation* (#439)
* Add methods *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (#440) * Add methods *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (#440)
1. Add methods: 3. Add methods:
* *TelegramBot#getFileStream* (#442) (by @GochoMugo, requested-by @Xaqron) * *TelegramBot#getFileStream* (#442) (by @GochoMugo, requested-by @Xaqron)
1. Add options to *TelegramBot#stopPolling()* (by @GochoMugo) 4. Add options to *TelegramBot#stopPolling()* (by @GochoMugo)
1. Add `metadata` argument in `message` event (and friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo) 5. Add `metadata` argument in `message` event (and friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
1. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo) 6. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo)
1. Add support for Node.js v9 (by @GochoMugo) 7. Add support for Node.js v9 (by @GochoMugo)
1. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo) 8. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo)
Changed: Changed:
1. Update *TelegramBot#answerCallbackQuery()* signature (by @GochoMugo) 1. Update *TelegramBot#answerCallbackQuery()* signature (by @GochoMugo)
1. Improve default error logging of `polling_error` and `webhook_error` (#377) 2. Improve default error logging of `polling_error` and `webhook_error` (#377)
1. Update dependencies 3. Update dependencies
Deprecated: Deprecated:
1. Sending files: *(See [usage guide][usage-sending-files])* (by @hufan-akari, @GochoMugo) 1. Sending files: *(See [usage guide][usage-sending-files])* (by @hufan-akari, @GochoMugo)
* Error will **not** be thrown if `Buffer` is used and file-type could **not** be detected. * Error will **not** be thrown if `Buffer` is used and file-type could **not** be detected.
* Filename will **not** be set to `data.${ext}` if `Buffer` is used * Filename will **not** be set to `data.${ext}` if `Buffer` is used
* Content type will **not** default to `null` or `undefined` * Content type will **not** default to `null` or `undefined`
Fixed: Fixed:
1. Fix the offset infinite loop bug (#265, #36) (by @GochoMugo) 1. Fix the offset infinite loop bug (#265, #36) (by @GochoMugo)
1. Fix game example (#449, #418) (by @MCSH) 2. Fix game example (#449, #418) (by @MCSH)
* * * * * *
@ -108,16 +136,15 @@ Fixed:
Added: Added:
1. Add Bot API v3.2 methods: 1. Add Bot API v3.2 methods:
* (#429) *TelegramBot#getStickerSet* (by @CapacitorSet, @LibertyLocked) * (#429) *TelegramBot#getStickerSet* (by @CapacitorSet, @LibertyLocked)
* (#430) *TelegramBot#uploadStickerFile* (by @CapacitorSet) * (#430) *TelegramBot#uploadStickerFile* (by @CapacitorSet)
* *TelegramBot#createNewStickerSet*, *TelegramBot#addStickerToSet*, *TelegramBot#setStickerPositionInSet*, *TelegramBot#deleteStickerFromSet* (by @GochoMugo) * *TelegramBot#createNewStickerSet*, *TelegramBot#addStickerToSet*, *TelegramBot#setStickerPositionInSet*, *TelegramBot#deleteStickerFromSet* (by @GochoMugo)
1. Supports API v3.3 2. Supports API v3.3
Deprecated: Deprecated:
1. Auto-enabling Promise cancellation (#319) (by @GochoMugo) 1. Auto-enabling Promise cancellation (#319) (by @GochoMugo)
* * * * * *
## [0.28.0][0.28.0] - 2017-08-06 ## [0.28.0][0.28.0] - 2017-08-06
@ -125,10 +152,10 @@ Deprecated:
Added: Added:
1. (#361) Support Bot API v3.1 (by @Lord-Protector, @kamikazechaser) 1. (#361) Support Bot API v3.1 (by @Lord-Protector, @kamikazechaser)
1. (#332) Support Bot API v3.0 (by @kamikazechaser, @GochoMugo) 2. (#332) Support Bot API v3.0 (by @kamikazechaser, @GochoMugo)
1. Add *TelegramBot#removeTextListener()* (by @GochoMugo) 3. Add *TelegramBot#removeTextListener()* (by @GochoMugo)
1. (#342) Add game example (by @MCSH) 4. (#342) Add game example (by @MCSH)
1. (#315) List 'bot-brother' project in community section in README (by @saeedhei) 5. (#315) List 'bot-brother' project in community section in README (by @saeedhei)
Changed: Changed:
@ -137,9 +164,8 @@ Changed:
Fixed: Fixed:
1. (#325) Fix global regexp state reset (by @Sirius-A) 1. (#325) Fix global regexp state reset (by @Sirius-A)
1. (#363) Fix download file path on windows (by @kucherenkovova) 2. (#363) Fix download file path on windows (by @kucherenkovova)
1. (#346) Fix anchor webhook link in docs (by @Coac) 3. (#346) Fix anchor webhook link in docs (by @Coac)
* * * * * *
@ -149,15 +175,13 @@ Added:
1. (#287) Add Express WebHook example (by @kamikazechaser) 1. (#287) Add Express WebHook example (by @kamikazechaser)
Fixed: Fixed:
1. (#291) Improve docs (by @preco21) 1. (#291) Improve docs (by @preco21)
1. (#298) Fix running on Node v5 (by @jehy) 2. (#298) Fix running on Node v5 (by @jehy)
1. (#307) Fix badge links in README (by @JaakkoLipsanen) 3. (#307) Fix badge links in README (by @JaakkoLipsanen)
1. Fix defaulting value of `options.polling.params.timeout` (by @GochoMugo) 4. Fix defaulting value of `options.polling.params.timeout` (by @GochoMugo)
1. Fix typos in Github issue template (by @GochoMugo, requested-by @GingerPlusPlus) 5. Fix typos in Github issue template (by @GochoMugo, requested-by @GingerPlusPlus)
* * * * * *
@ -166,19 +190,19 @@ Fixed:
Added: Added:
1. Add constructor options: 1. Add constructor options:
* (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux) * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux)
1. Add methods: 2. Add methods:
* (#74) *TelegramBot#removeReplyListener()* (by @githugger) * (#74) *TelegramBot#removeReplyListener()* (by @githugger)
1. (#283) Add proper error handling (by @GochoMugo) 3. (#283) Add proper error handling (by @GochoMugo)
1. (#272) Add health-check endpoint (by @mironov) 4. (#272) Add health-check endpoint (by @mironov)
* `options.webHook.healthEndpoint` * `options.webHook.healthEndpoint`
1. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts' 5. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts'
param (by @evolun) param (by @evolun)
1. Document `options.webHook.host` (by @GochoMugo) 6. Document `options.webHook.host` (by @GochoMugo)
1. (#264) Add Bot API version to README (by @kamikazechaser) 7. (#264) Add Bot API version to README (by @kamikazechaser)
1. Add examples: 8. Add examples:
- (#271) WebHook on Heroku (by @TheBeastOfCaerbannog) - (#271) WebHook on Heroku (by @TheBeastOfCaerbannog)
- (#274) WebHook on Zeit Now (by @Ferrari) - (#274) WebHook on Zeit Now (by @Ferrari)
Changed: Changed:
@ -197,7 +221,6 @@ Fixed:
polling (by @GochoMugo, reported-by @dcparga) polling (by @GochoMugo, reported-by @dcparga)
1. Fix links in documentation (by @Ni2c2k) 1. Fix links in documentation (by @Ni2c2k)
* * * * * *
## [0.26.0][0.26.0] - 2017-01-20 ## [0.26.0][0.26.0] - 2017-01-20
@ -205,32 +228,32 @@ Fixed:
Added: Added:
1. Add *TelegramBot* constructor options: 1. Add *TelegramBot* constructor options:
* `options.https` * `options.https`
* `options.baseApiUrl` * `options.baseApiUrl`
* `options.filepath` * `options.filepath`
1. Add methods: 2. Add methods:
* *TelegramBot#stopPolling()* * *TelegramBot#stopPolling()*
* *TelegramBot#isPolling()* * *TelegramBot#isPolling()*
* *TelegramBot#openWebHook()* * *TelegramBot#openWebHook()*
* *TelegramBot#closeWebHook()* * *TelegramBot#closeWebHook()*
* *TelegramBot#hasOpenWebHook()* * *TelegramBot#hasOpenWebHook()*
* *TelegramBot#deleteWebHook()* * *TelegramBot#deleteWebHook()*
* *TelegramBot#getWebHookInfo()* * *TelegramBot#getWebHookInfo()*
Changed: Changed:
1. Use POST requests by default 1. Use POST requests by default
1. Ensure all relevant methods return Promises 2. Ensure all relevant methods return Promises
1. Document auto-deletion of webhook during polling 3. Document auto-deletion of webhook during polling
1. Deprecate support for Node.js v0.12 4. Deprecate support for Node.js v0.12
1. Fix consistency of methods signatures 5. Fix consistency of methods signatures
1. Rename *TelegramBot#initPolling()* to *TelegramBot#startPolling()* 6. Rename *TelegramBot#initPolling()* to *TelegramBot#startPolling()*
* Deprecate *TelegramBot#initPolling()* * Deprecate *TelegramBot#initPolling()*
Fixed: Fixed:
1. Handle error during formatting `formData` 1. Handle error during formatting `formData`
1. Fix ES6 syntax 2. Fix ES6 syntax
*Credits/Blames: Unless explicitly stated otherwise, above work was *Credits/Blames: Unless explicitly stated otherwise, above work was
done by @GochoMugo* done by @GochoMugo*
@ -242,19 +265,18 @@ done by @GochoMugo*
Added: Added:
1. Supports the API v2.3 updates (by @kamikazechaser) 1. Supports the API v2.3 updates (by @kamikazechaser)
1. Add *TelegramBot* constructor option: 2. Add *TelegramBot* constructor option:
* `options.request`: proxy extra request options (by @tarmolov) * `options.request`: proxy extra request options (by @tarmolov)
* `options.onlyFirstMatch` (by @GingerPlusPlus) * `options.onlyFirstMatch` (by @GingerPlusPlus)
1. Add methods: 3. Add methods:
* *TelegramBot#sendVenue()* (by Tketa) * *TelegramBot#sendVenue()* (by Tketa)
* *TelegramBot#sendContact()* (by @GochoMugo) * *TelegramBot#sendContact()* (by @GochoMugo)
* *TelegramBot#getGameHighScores()* (by @jishnu7) * *TelegramBot#getGameHighScores()* (by @jishnu7)
Fixed: Fixed:
1. Fix request performance issue (by @preco21) 1. Fix request performance issue (by @preco21)
1. Fix typos (by oflisback) 2. Fix typos (by oflisback)
[usage-sending-files]:https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files-options [usage-sending-files]:https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files-options

View File

@ -4,7 +4,7 @@
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api). 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.5.0-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) [![Bot API](https://img.shields.io/badge/Bot%20API-v.5.1-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) [![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) [![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) [![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)

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "node-telegram-bot-api", "name": "node-telegram-bot-api",
"version": "0.51.0", "version": "0.52.0",
"description": "Telegram Bot API", "description": "Telegram Bot API",
"main": "./index.js", "main": "./index.js",
"directories": { "directories": {

View File

@ -48,6 +48,12 @@ const _messageTypes = [
'video', 'video',
'video_note', 'video_note',
'voice', 'voice',
'voice_chat_started',
'voice_chat_ended',
'voice_chat_participants_invited',
'message_auto_delete_timer_changed',
'chat_invite_link',
'chat_member_updated'
]; ];
const _deprecatedMessageTypes = [ const _deprecatedMessageTypes = [
'new_chat_participant', 'left_chat_participant' 'new_chat_participant', 'left_chat_participant'
@ -615,6 +621,8 @@ class TelegramBot extends EventEmitter {
const preCheckoutQuery = update.pre_checkout_query; const preCheckoutQuery = update.pre_checkout_query;
const poll = update.poll; const poll = update.poll;
const pollAnswer = update.poll_answer; const pollAnswer = update.poll_answer;
const chatMember = update.chat_member;
const myChatMember = update.my_chat_member;
if (message) { if (message) {
debug('Process Update message %j', message); debug('Process Update message %j', message);
@ -698,6 +706,12 @@ class TelegramBot extends EventEmitter {
} else if (pollAnswer) { } else if (pollAnswer) {
debug('Process Update poll_answer %j', pollAnswer); debug('Process Update poll_answer %j', pollAnswer);
this.emit('poll_answer', pollAnswer); this.emit('poll_answer', pollAnswer);
} else if (chatMember) {
debug('Process Update chat_member %j', chatMember);
this.emit('chat_member', chatMember);
} else if (myChatMember) {
debug('Process Update my_chat_member %j', myChatMember);
this.emit('my_chat_member', myChatMember);
} }
} }
@ -1140,6 +1154,56 @@ class TelegramBot extends EventEmitter {
return this._request('exportChatInviteLink', { form }); return this._request('exportChatInviteLink', { form });
} }
/**
* Use this method to create an additional invite link for a chat.
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns the new invite link as ChatInviteLink object.
*
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup
* @param {Object} [options] Additional Telegram query options
* @return {Object} ChatInviteLink
* @see https://core.telegram.org/bots/api#createchatinvitelink
*/
createChatInviteLink(chatId, form = {}) {
form.chat_id = chatId;
return this._request('createChatInviteLink', { form });
}
/**
* Use this method to edit a non-primary invite link created by the bot.
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns the edited invite link as a ChatInviteLink object.
*
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup
* @param {String} inviteLink Text with the invite link to edit
* @param {Object} [options] Additional Telegram query options
* @return {Object} ChatInviteLink
* @see https://core.telegram.org/bots/api#editchatinvitelink
*/
editChatInviteLink(chatId, inviteLink, form = {}) {
form.chat_id = chatId;
form.invite_link = inviteLink;
return this._request('editChatInviteLink', { form });
}
/**
* Use this method to revoke an invite link created by the bot.
* Note: If the primary link is revoked, a new link is automatically generated
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns the revoked invite link as ChatInviteLink object.
*
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup
* @param {Object} [options] Additional Telegram query options
* @return {Object} ChatInviteLink
* @see https://core.telegram.org/bots/api#revokechatinvitelink
*/
revokeChatInviteLink(chatId, inviteLink, form = {}) {
form.chat_id = chatId;
form.invite_link = inviteLink;
return this._request('revokeChatInviteLink', { form });
}
/** /**
* Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
@ -1248,16 +1312,16 @@ class TelegramBot extends EventEmitter {
return this._request('unpinChatMessage', { form }); return this._request('unpinChatMessage', { form });
} }
/** /**
* Use this method to clear the list of pinned messages in a chat * Use this method to clear the list of pinned messages in a chat
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns True on success. * Returns True on success.
* *
* @param {Number|String} chatId Unique identifier for the message recipient * @param {Number|String} chatId Unique identifier for the message recipient
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#unpinallchatmessages * @see https://core.telegram.org/bots/api#unpinallchatmessages
*/ */
unpinAllChatMessages(chatId, form = {}) { unpinAllChatMessages(chatId, form = {}) {
form.chat_id = chatId; form.chat_id = chatId;
return this._request('unpinAllChatMessages', { form }); return this._request('unpinAllChatMessages', { form });

View File

@ -901,6 +901,33 @@ describe('TelegramBot', function telegramSuite() {
}); });
}); });
describe('#createChatInviteLink', function createChatInviteLinkSuite() {
let inviteLink;
before(function before() {
utils.handleRatelimit(bot, 'createChatInviteLink', this);
utils.handleRatelimit(bot, 'editChatInviteLink', this);
utils.handleRatelimit(bot, 'revokeChatInviteLink', this);
});
it('should create a chat invite link', function test() {
return bot.createChatInviteLink(GROUPID).then(resp => {
assert(resp.invite_link.match(/^https:\/\/t\.me\/joinchat\/.+$/i), 'is a telegram invite link');
inviteLink = resp.invite_link;
});
});
it('should edit chat invite link', function test() {
return bot.editChatInviteLink(GROUPID, inviteLink, { member_limit: 3 }).then(resp => {
assert.strictEqual(resp.member_limit, 3);
});
});
it('should revoke chat invite link', function test() {
return bot.revokeChatInviteLink(GROUPID, inviteLink).then(resp => {
assert.strictEqual(resp.is_revoked, true);
});
});
});
describe('#setChatPhoto', function setChatPhotoSuite() { describe('#setChatPhoto', function setChatPhotoSuite() {
this.timeout(timeout); this.timeout(timeout);
before(function before() { before(function before() {