From de76dcd2cba04d854de9097e2804fde62bd4eacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=C3=A9rez=20Fern=C3=A1ndez?= Date: Mon, 29 Mar 2021 16:37:10 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 234 ++++++++------- README.md | 2 +- doc/api.md | 766 ++++++++++++++++++++--------------------------- package.json | 2 +- src/telegram.js | 84 +++++- test/telegram.js | 27 ++ 6 files changed, 563 insertions(+), 552 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddd59c6..ac3a311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,24 +3,52 @@ All notable changes to this project will be documented in this file. 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 Added: 1. Support Bot API v5.0: (by @danielperez9430) - * Add method *copyMessage()* - * Add method *unpinAllChatMessages()* - * Add method *close()* - * Add method *logOut()* - - Changed: (by @danielperez9430) - * Remove trailing-spaces - * Fix Bugs in Test - - New Test: (by @danielperez9430) - * copyMessage - * unpinAllChatMessages - + + * Add method *copyMessage()* + * Add method *unpinAllChatMessages()* + * Add method *close()* + * Add method *logOut()* + + Changed: (by @danielperez9430) + + * Remove trailing-spaces + * Fix Bugs in Test + + New Test: (by @danielperez9430) + + * copyMessage + * unpinAllChatMessages ## [0.50.0][0.50.0] - 2020-05-2020 @@ -28,27 +56,29 @@ Added: 1. Support Bot API v4.8: (by @danielperez9430) * Add methods: *sendDice()* -1. Support Bot API v4.7: (by @danielperez9430) +2. Support Bot API v4.7: (by @danielperez9430) * Add methods: *getMyCommands()*,*setMyCommands()* -1. Support Bot API v4.5: (by @danielperez9430) +3. Support Bot API v4.5: (by @danielperez9430) * Add methods: *setChatAdministratorCustomTitle()* -1. Support Bot API v4.4: (by @danielperez9430) +4. Support Bot API v4.4: (by @danielperez9430) * Add methods: *setChatPermissions()* -1. Support for poll_answer (by @JieJiSS) -1. Add request options in file stream (by @zhangpanyi ) +5. Support for poll_answer (by @JieJiSS) +6. Add request options in file stream (by @zhangpanyi ) Changed: (by @danielperez9430) - * New message type: *dice* - * Fix Bugs in tests - * Fix regex compare (by @ledamint) - * Fix listening for error events when downloading files (by @Kraigo) + +* New message type: *dice* +* Fix Bugs in tests +* Fix regex compare (by @ledamint) +* Fix listening for error events when downloading files (by @Kraigo) New Test: (by @danielperez9430) - * sendDice - * getMyCommands - * setMyCommands - * setChatAdministratorCustomTitle - * setChatPermissions + +* sendDice +* getMyCommands +* setMyCommands +* setChatAdministratorCustomTitle +* setChatPermissions ## [0.40.0][0.40.0] - 2019-05-04 @@ -57,11 +87,10 @@ Added: 1. Support Bot API v4.2: (by @kamikazechaser) * Add methods: *TelegramBot#sendPoll()*, *TelegramBot#stopPoll()* * 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()* * Support new message types: *passport_data*, *animation* - * * * ## [0.30.0][0.30.0] - 2017-12-21 @@ -69,37 +98,36 @@ Added: Added: 1. Support Bot API v3.5: (by @GochoMugo) - * Allow `provider_data` parameter in *TelegramBot#sendInvoice* - * Add method *TelegramBot#sendMediaGroup()* -1. Support Bot API v3.4: (by @kamikazechaser) - * Add methods *TelegramBot#editMessageLiveLocation*, *TelegramBot#stopMessageLiveLocation* (#439) - * Add methods *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (#440) -1. Add methods: - * *TelegramBot#getFileStream* (#442) (by @GochoMugo, requested-by @Xaqron) -1. 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) -1. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo) -1. Add support for Node.js v9 (by @GochoMugo) -1. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo) + * Allow `provider_data` parameter in *TelegramBot#sendInvoice* + * Add method *TelegramBot#sendMediaGroup()* +2. Support Bot API v3.4: (by @kamikazechaser) + * Add methods *TelegramBot#editMessageLiveLocation*, *TelegramBot#stopMessageLiveLocation* (#439) + * Add methods *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (#440) +3. Add methods: + * *TelegramBot#getFileStream* (#442) (by @GochoMugo, requested-by @Xaqron) +4. Add options to *TelegramBot#stopPolling()* (by @GochoMugo) +5. Add `metadata` argument in `message` event (and friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo) +6. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo) +7. Add support for Node.js v9 (by @GochoMugo) +8. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo) Changed: 1. Update *TelegramBot#answerCallbackQuery()* signature (by @GochoMugo) -1. Improve default error logging of `polling_error` and `webhook_error` (#377) -1. Update dependencies +2. Improve default error logging of `polling_error` and `webhook_error` (#377) +3. Update dependencies Deprecated: 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. - * Filename will **not** be set to `data.${ext}` if `Buffer` is used - * Content type will **not** default to `null` or `undefined` + * 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 + * Content type will **not** default to `null` or `undefined` Fixed: 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: 1. Add Bot API v3.2 methods: - * (#429) *TelegramBot#getStickerSet* (by @CapacitorSet, @LibertyLocked) - * (#430) *TelegramBot#uploadStickerFile* (by @CapacitorSet) - * *TelegramBot#createNewStickerSet*, *TelegramBot#addStickerToSet*, *TelegramBot#setStickerPositionInSet*, *TelegramBot#deleteStickerFromSet* (by @GochoMugo) -1. Supports API v3.3 + * (#429) *TelegramBot#getStickerSet* (by @CapacitorSet, @LibertyLocked) + * (#430) *TelegramBot#uploadStickerFile* (by @CapacitorSet) + * *TelegramBot#createNewStickerSet*, *TelegramBot#addStickerToSet*, *TelegramBot#setStickerPositionInSet*, *TelegramBot#deleteStickerFromSet* (by @GochoMugo) +2. Supports API v3.3 Deprecated: 1. Auto-enabling Promise cancellation (#319) (by @GochoMugo) - * * * ## [0.28.0][0.28.0] - 2017-08-06 @@ -125,10 +152,10 @@ Deprecated: Added: 1. (#361) Support Bot API v3.1 (by @Lord-Protector, @kamikazechaser) -1. (#332) Support Bot API v3.0 (by @kamikazechaser, @GochoMugo) -1. Add *TelegramBot#removeTextListener()* (by @GochoMugo) -1. (#342) Add game example (by @MCSH) -1. (#315) List 'bot-brother' project in community section in README (by @saeedhei) +2. (#332) Support Bot API v3.0 (by @kamikazechaser, @GochoMugo) +3. Add *TelegramBot#removeTextListener()* (by @GochoMugo) +4. (#342) Add game example (by @MCSH) +5. (#315) List 'bot-brother' project in community section in README (by @saeedhei) Changed: @@ -137,9 +164,8 @@ Changed: Fixed: 1. (#325) Fix global regexp state reset (by @Sirius-A) -1. (#363) Fix download file path on windows (by @kucherenkovova) -1. (#346) Fix anchor webhook link in docs (by @Coac) - +2. (#363) Fix download file path on windows (by @kucherenkovova) +3. (#346) Fix anchor webhook link in docs (by @Coac) * * * @@ -149,15 +175,13 @@ Added: 1. (#287) Add Express WebHook example (by @kamikazechaser) - Fixed: 1. (#291) Improve docs (by @preco21) -1. (#298) Fix running on Node v5 (by @jehy) -1. (#307) Fix badge links in README (by @JaakkoLipsanen) -1. Fix defaulting value of `options.polling.params.timeout` (by @GochoMugo) -1. Fix typos in Github issue template (by @GochoMugo, requested-by @GingerPlusPlus) - +2. (#298) Fix running on Node v5 (by @jehy) +3. (#307) Fix badge links in README (by @JaakkoLipsanen) +4. Fix defaulting value of `options.polling.params.timeout` (by @GochoMugo) +5. Fix typos in Github issue template (by @GochoMugo, requested-by @GingerPlusPlus) * * * @@ -166,19 +190,19 @@ Fixed: Added: 1. Add constructor options: - * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux) -1. Add methods: - * (#74) *TelegramBot#removeReplyListener()* (by @githugger) -1. (#283) Add proper error handling (by @GochoMugo) -1. (#272) Add health-check endpoint (by @mironov) - * `options.webHook.healthEndpoint` -1. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts' + * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux) +2. Add methods: + * (#74) *TelegramBot#removeReplyListener()* (by @githugger) +3. (#283) Add proper error handling (by @GochoMugo) +4. (#272) Add health-check endpoint (by @mironov) + * `options.webHook.healthEndpoint` +5. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts' param (by @evolun) -1. Document `options.webHook.host` (by @GochoMugo) -1. (#264) Add Bot API version to README (by @kamikazechaser) -1. Add examples: - - (#271) WebHook on Heroku (by @TheBeastOfCaerbannog) - - (#274) WebHook on Zeit Now (by @Ferrari) +6. Document `options.webHook.host` (by @GochoMugo) +7. (#264) Add Bot API version to README (by @kamikazechaser) +8. Add examples: + - (#271) WebHook on Heroku (by @TheBeastOfCaerbannog) + - (#274) WebHook on Zeit Now (by @Ferrari) Changed: @@ -197,7 +221,6 @@ Fixed: polling (by @GochoMugo, reported-by @dcparga) 1. Fix links in documentation (by @Ni2c2k) - * * * ## [0.26.0][0.26.0] - 2017-01-20 @@ -205,32 +228,32 @@ Fixed: Added: 1. Add *TelegramBot* constructor options: - * `options.https` - * `options.baseApiUrl` - * `options.filepath` -1. Add methods: - * *TelegramBot#stopPolling()* - * *TelegramBot#isPolling()* - * *TelegramBot#openWebHook()* - * *TelegramBot#closeWebHook()* - * *TelegramBot#hasOpenWebHook()* - * *TelegramBot#deleteWebHook()* - * *TelegramBot#getWebHookInfo()* + * `options.https` + * `options.baseApiUrl` + * `options.filepath` +2. Add methods: + * *TelegramBot#stopPolling()* + * *TelegramBot#isPolling()* + * *TelegramBot#openWebHook()* + * *TelegramBot#closeWebHook()* + * *TelegramBot#hasOpenWebHook()* + * *TelegramBot#deleteWebHook()* + * *TelegramBot#getWebHookInfo()* Changed: 1. Use POST requests by default -1. Ensure all relevant methods return Promises -1. Document auto-deletion of webhook during polling -1. Deprecate support for Node.js v0.12 -1. Fix consistency of methods signatures -1. Rename *TelegramBot#initPolling()* to *TelegramBot#startPolling()* - * Deprecate *TelegramBot#initPolling()* +2. Ensure all relevant methods return Promises +3. Document auto-deletion of webhook during polling +4. Deprecate support for Node.js v0.12 +5. Fix consistency of methods signatures +6. Rename *TelegramBot#initPolling()* to *TelegramBot#startPolling()* + * Deprecate *TelegramBot#initPolling()* Fixed: 1. Handle error during formatting `formData` -1. Fix ES6 syntax +2. Fix ES6 syntax *Credits/Blames: Unless explicitly stated otherwise, above work was done by @GochoMugo* @@ -242,19 +265,18 @@ done by @GochoMugo* Added: 1. Supports the API v2.3 updates (by @kamikazechaser) -1. Add *TelegramBot* constructor option: - * `options.request`: proxy extra request options (by @tarmolov) - * `options.onlyFirstMatch` (by @GingerPlusPlus) -1. Add methods: - * *TelegramBot#sendVenue()* (by Tketa) - * *TelegramBot#sendContact()* (by @GochoMugo) - * *TelegramBot#getGameHighScores()* (by @jishnu7) +2. Add *TelegramBot* constructor option: + * `options.request`: proxy extra request options (by @tarmolov) + * `options.onlyFirstMatch` (by @GingerPlusPlus) +3. Add methods: + * *TelegramBot#sendVenue()* (by Tketa) + * *TelegramBot#sendContact()* (by @GochoMugo) + * *TelegramBot#getGameHighScores()* (by @jishnu7) Fixed: 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 diff --git a/README.md b/README.md index 6b4f04a..8cb6d25 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,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.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) [![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) diff --git a/doc/api.md b/doc/api.md index 757f70d..81fa3e9 100644 --- a/doc/api.md +++ b/doc/api.md @@ -1,14 +1,14 @@ -# API Reference - -**Note:** If you are looking for available [events](usage.md#events) or usage of api, please refer [`usage.md`](usage.md). - +# API Reference + +**Note:** If you are looking for available [events](usage.md#events) or usage of api, please refer [`usage.md`](usage.md). + ## TelegramBot TelegramBot -**Kind**: global class -**See**: https://core.telegram.org/bots/api +**Kind**: global class +**See**: https://core.telegram.org/bots/api * [TelegramBot](#TelegramBot) * [new TelegramBot(token, [options])](#new_TelegramBot_new) @@ -35,6 +35,7 @@ TelegramBot * [.copyMessage(chatId, fromChatId, messageId, [options])](#TelegramBot+copyMessage) ⇒ Promise * [.sendPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+sendPhoto) ⇒ Promise * [.sendAudio(chatId, audio, [options], [fileOptions])](#TelegramBot+sendAudio) ⇒ Promise + * [.sendDice(chatId, [options])](#TelegramBot+sendDice) ⇒ Promise * [.sendDocument(chatId, doc, [options], [fileOptions])](#TelegramBot+sendDocument) ⇒ Promise * [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ Promise * [.sendVideo(chatId, video, [options], [fileOptions])](#TelegramBot+sendVideo) ⇒ Promise @@ -47,8 +48,11 @@ TelegramBot * [.restrictChatMember(chatId, userId, [options])](#TelegramBot+restrictChatMember) ⇒ Promise * [.promoteChatMember(chatId, userId, [options])](#TelegramBot+promoteChatMember) ⇒ Promise * [.setChatAdministratorCustomTitle(chatId, userId, customTitle, [options])](#TelegramBot+setChatAdministratorCustomTitle) ⇒ Promise - * [.setChatPermissions(chatId, ChatPermissions, [options])](#TelegramBot+setChatPermissions) ⇒ Promise + * [.setChatPermissions(chatId, chatPermissions, [options])](#TelegramBot+setChatPermissions) ⇒ Promise * [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ Promise + * [.createChatInviteLink(chatId, [options])](#TelegramBot+createChatInviteLink) ⇒ Object + * [.editChatInviteLink(chatId, inviteLink, [options])](#TelegramBot+editChatInviteLink) ⇒ Object + * [.revokeChatInviteLink(chatId, [options])](#TelegramBot+revokeChatInviteLink) ⇒ Object * [.setChatPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+setChatPhoto) ⇒ Promise * [.deleteChatPhoto(chatId, [options])](#TelegramBot+deleteChatPhoto) ⇒ Promise * [.setChatTitle(chatId, title, [options])](#TelegramBot+setChatTitle) ⇒ Promise @@ -71,16 +75,15 @@ TelegramBot * [.sendContact(chatId, phoneNumber, firstName, [options])](#TelegramBot+sendContact) ⇒ Promise * [.sendPoll(chatId, question, pollOptions, [options])](#TelegramBot+sendPoll) ⇒ Promise * [.stopPoll(chatId, pollId, [options])](#TelegramBot+stopPoll) ⇒ Promise - * [.sendDice(chatId, [options])](#TelegramBot+sendDice) ⇒ Promise * [.getFile(fileId, [options])](#TelegramBot+getFile) ⇒ Promise * [.getFileLink(fileId, [options])](#TelegramBot+getFileLink) ⇒ Promise * [.getFileStream(fileId, [options])](#TelegramBot+getFileStream) ⇒ stream.Readable * [.downloadFile(fileId, downloadDir, [options])](#TelegramBot+downloadFile) ⇒ Promise * [.onText(regexp, callback)](#TelegramBot+onText) * [.removeTextListener(regexp)](#TelegramBot+removeTextListener) ⇒ Object + * [.clearTextListeners()](#TelegramBot+clearTextListeners) * [.onReplyToMessage(chatId, messageId, callback)](#TelegramBot+onReplyToMessage) ⇒ Number * [.removeReplyListener(replyListenerId)](#TelegramBot+removeReplyListener) ⇒ Object - * [.clearTextListeners()](#TelegramBot+clearTextListeners) * [.clearReplyListeners()](#TelegramBot+clearReplyListeners) * [.getChat(chatId, [options])](#TelegramBot+getChat) ⇒ Promise * [.getChatAdministrators(chatId, [options])](#TelegramBot+getChatAdministrators) ⇒ Promise @@ -105,15 +108,13 @@ TelegramBot * [.sendMediaGroup(chatId, media, [options])](#TelegramBot+sendMediaGroup) ⇒ Promise * _static_ * [.errors](#TelegramBot.errors) : Object - * [.messageTypes](#TelegramBot.messageTypes) : Array.<String> + * [.messageTypes](#TelegramBot.messageTypes) : [ 'Array' ].<String> * [.Promise](#TelegramBot.Promise) ### new TelegramBot(token, [options]) -Both request method to obtain messages are implemented. To use standard polling, set `polling: true` -on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a SSL certificate. -Emits `message` when a message arrives. +Both request method to obtain messages are implemented. To use standard polling, set `polling: true` on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a SSL certificate. Emits `message` when a message arrives. | Param | Type | Default | Description | @@ -144,10 +145,9 @@ Emits `message` when a message arrives. ### telegramBot.on(event, listener) -Add listener for the specified [event](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events). -This is the usual `emitter.on()` method. +Add listener for the specified [event](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events). This is the usual `emitter.on()` method. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - [Available events](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events) @@ -156,16 +156,15 @@ This is the usual `emitter.on()` method. | Param | Type | | --- | --- | -| event | String | -| listener | function | +| event | String | +| listener | function | ### telegramBot.startPolling([options]) ⇒ Promise -Start polling. -Rejects returned promise if a WebHook is being used by this instance. +Start polling. Rejects returned promise if a WebHook is being used by this instance. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) | Param | Type | Default | Description | | --- | --- | --- | --- | @@ -179,20 +178,18 @@ Rejects returned promise if a WebHook is being used by this instance. Alias of `TelegramBot#startPolling()`. This is **deprecated**. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) | Param | Type | | --- | --- | -| [options] | Object | +| [options] | Object | ### telegramBot.stopPolling([options]) ⇒ Promise -Stops polling after the last polling request resolves. -Multiple invocations do nothing if polling is already stopped. -Returning the promise of the last polling request is **deprecated**. +Stops polling after the last polling request resolves. Multiple invocations do nothing if polling is already stopped. Returning the promise of the last polling request is **deprecated**. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) | Param | Type | Description | | --- | --- | --- | @@ -205,37 +202,33 @@ Returning the promise of the last polling request is **deprecated**. ### telegramBot.isPolling() ⇒ Boolean Return true if polling. Otherwise, false. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) ### telegramBot.openWebHook() ⇒ Promise -Open webhook. -Multiple invocations do nothing if webhook is already open. -Rejects returned promise if Polling is being used by this instance. +Open webhook. Multiple invocations do nothing if webhook is already open. Rejects returned promise if Polling is being used by this instance. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) ### telegramBot.closeWebHook() ⇒ Promise -Close webhook after closing all current connections. -Multiple invocations do nothing if webhook is already closed. +Close webhook after closing all current connections. Multiple invocations do nothing if webhook is already closed. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: Promise - promise +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - promise ### telegramBot.hasOpenWebHook() ⇒ Boolean -Return true if using webhook and it is open i.e. accepts connections. -Otherwise, false. +Return true if using webhook and it is open i.e. accepts connections. Otherwise, false. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) ### telegramBot.getMe([options]) ⇒ Promise Returns basic information about the bot in form of a `User` object. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getme +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getme | Param | Type | Description | | --- | --- | --- | @@ -244,13 +237,10 @@ Returns basic information about the bot in form of a `User` object. ### telegramBot.logOut([options]) ⇒ Promise -This method log out your bot from the cloud Bot API server before launching the bot locally. -You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. -After a successful call, you will not be able to log in again using the same token for 10 minutes. -Returns True on success. +This method log out your bot from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you will not be able to log in again using the same token for 10 minutes. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#logout +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#logout | Param | Type | Description | | --- | --- | --- | @@ -259,12 +249,10 @@ Returns True on success. ### telegramBot.close([options]) ⇒ Promise -This method close the bot instance before moving it from one local server to another. -This method will return error 429 in the first 10 minutes after the bot is launched. -Returns True on success. +This method close the bot instance before moving it from one local server to another. This method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#close +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#close | Param | Type | Description | | --- | --- | --- | @@ -273,11 +261,9 @@ Returns True on success. ### telegramBot.setWebHook(url, [options], [fileOptions]) ⇒ Promise -Specify an url to receive incoming updates via an outgoing webHook. -This method has an [older, compatible signature][setWebHook-v0.25.0] -that is being deprecated. +Specify an url to receive incoming updates via an outgoing webHook. This method has an [older, compatible signature][setWebHook-v0.25.0] that is being deprecated. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#setwebhook @@ -294,11 +280,10 @@ that is being deprecated. ### telegramBot.deleteWebHook([options]) ⇒ Promise -Use this method to remove webhook integration if you decide to -switch back to getUpdates. Returns True on success. +Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#deletewebhook +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#deletewebhook | Param | Type | Description | | --- | --- | --- | @@ -307,13 +292,10 @@ switch back to getUpdates. Returns True on success. ### telegramBot.getWebHookInfo([options]) ⇒ Promise -Use this method to get current webhook status. -On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object. -If the bot is using getUpdates, will return an object with the -url field empty. +Use this method to get current webhook status. On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object. If the bot is using getUpdates, will return an object with the url field empty. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getwebhookinfo +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getwebhookinfo | Param | Type | Description | | --- | --- | --- | @@ -322,12 +304,10 @@ url field empty. ### telegramBot.getUpdates([options]) ⇒ Promise -Use this method to receive incoming updates using long polling. -This method has an [older, compatible signature][getUpdates-v0.25.0] -that is being deprecated. +Use this method to receive incoming updates using long polling. This method has an [older, compatible signature][getUpdates-v0.25.0] that is being deprecated. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getupdates +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getupdates | Param | Type | Description | | --- | --- | --- | @@ -336,24 +316,22 @@ that is being deprecated. ### telegramBot.processUpdate(update) -Process an update; emitting the proper events and executing regexp -callbacks. This method is useful should you be using a different -way to fetch updates, other than those provided by TelegramBot. +Process an update; emitting the proper events and executing regexp callbacks. This method is useful should you be using a different way to fetch updates, other than those provided by TelegramBot. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#update +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#update | Param | Type | | --- | --- | -| update | Object | +| update | Object | ### telegramBot.sendMessage(chatId, text, [options]) ⇒ Promise Send text message. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendmessage +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendmessage | Param | Type | Description | | --- | --- | --- | @@ -366,13 +344,13 @@ Send text message. ### telegramBot.answerInlineQuery(inlineQueryId, results, [options]) ⇒ Promise Send answers to an inline query. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#answerinlinequery +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#answerinlinequery | Param | Type | Description | | --- | --- | --- | | inlineQueryId | String | Unique identifier of the query | -| results | Array.<InlineQueryResult> | An array of results for the inline query | +| results | [ 'Array' ].<InlineQueryResult> | An array of results for the inline query | | [options] | Object | Additional Telegram query options | @@ -380,7 +358,8 @@ Send answers to an inline query. ### telegramBot.forwardMessage(chatId, fromChatId, messageId, [options]) ⇒ Promise Forward messages of any kind. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#forwardmessage | Param | Type | Description | | --- | --- | --- | @@ -392,9 +371,10 @@ Forward messages of any kind. ### telegramBot.copyMessage(chatId, fromChatId, messageId, [options]) ⇒ Promise -Copy messages of any kind. +Copy messages of any kind. The method is analogous to the method forwardMessages, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#copymessage | Param | Type | Description | | --- | --- | --- | @@ -408,7 +388,7 @@ Copy messages of any kind. ### telegramBot.sendPhoto(chatId, photo, [options], [fileOptions]) ⇒ Promise Send photo -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendphoto @@ -427,7 +407,7 @@ Send photo ### telegramBot.sendAudio(chatId, audio, [options], [fileOptions]) ⇒ Promise Send audio -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendaudio @@ -441,12 +421,25 @@ Send audio | [options] | Object | Additional Telegram query options | | [fileOptions] | Object | Optional file related meta-data | + + +### telegramBot.sendDice(chatId, [options]) ⇒ Promise +Send Dice Use this method to send a dice. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#senddice + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number \| String | Unique identifier for the message recipient | +| [options] | Object | Additional Telegram query options | + ### telegramBot.sendDocument(chatId, doc, [options], [fileOptions]) ⇒ Promise Send Document -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendDocument @@ -465,8 +458,8 @@ Send Document ### telegramBot.sendSticker(chatId, sticker, [options], [fileOptions]) ⇒ Promise Send .webp stickers. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendsticker +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendsticker | Param | Type | Description | | --- | --- | --- | @@ -480,7 +473,7 @@ Send .webp stickers. ### telegramBot.sendVideo(chatId, video, [options], [fileOptions]) ⇒ Promise Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendvideo @@ -499,7 +492,7 @@ Use this method to send video files, Telegram clients support mp4 videos (other ### telegramBot.sendAnimation(chatId, animation, [options], [fileOptions]) ⇒ Promise Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendanimation @@ -518,8 +511,8 @@ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without s ### telegramBot.sendVideoNote(chatId, videoNote, [options], [fileOptions]) ⇒ Promise Use this method to send rounded square videos of upto 1 minute long. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Info**: The length parameter is actually optional. However, the API (at time of writing) requires you to always provide it until it is fixed. +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Info**: The length parameter is actually optional. However, the API (at time of writing) requires you to always provide it until it is fixed. **See** - https://core.telegram.org/bots/api#sendvideonote @@ -538,7 +531,7 @@ Use this method to send rounded square videos of upto 1 minute long. ### telegramBot.sendVoice(chatId, voice, [options], [fileOptions]) ⇒ Promise Send voice -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendvoice @@ -555,14 +548,10 @@ Send voice ### telegramBot.sendChatAction(chatId, action, [options]) ⇒ Promise -Send chat action. -`typing` for text messages, -`upload_photo` for photos, `record_video` or `upload_video` for videos, -`record_audio` or `upload_audio` for audio files, `upload_document` for general files, -`find_location` for location data. +Send chat action. `typing` for text messages, `upload_photo` for photos, `record_video` or `upload_video` for videos, `record_audio` or `upload_audio` for audio files, `upload_document` for general files, `find_location` for location data. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendchataction +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendchataction | Param | Type | Description | | --- | --- | --- | @@ -573,14 +562,10 @@ Send chat action. ### telegramBot.kickChatMember(chatId, userId, [options]) ⇒ Promise -Use this method to kick a user from a group or a supergroup. -In the case of supergroups, the user will not be able to return -to the group on their own using invite links, etc., unless unbanned -first. The bot must be an administrator in the group for this to work. -Returns True on success. +Use this method to kick a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#kickchatmember +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#kickchatmember | Param | Type | Description | | --- | --- | --- | @@ -591,13 +576,10 @@ Returns True on success. ### telegramBot.unbanChatMember(chatId, userId, [options]) ⇒ Promise -Use this method to unban a previously kicked user in a supergroup. -The user will not return to the group automatically, but will be -able to join via link, etc. The bot must be an administrator in -the group for this to work. Returns True on success. +Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#unbanchatmember +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#unbanchatmember | Param | Type | Description | | --- | --- | --- | @@ -608,13 +590,10 @@ the group for this to work. Returns True on success. ### telegramBot.restrictChatMember(chatId, userId, [options]) ⇒ Promise -Use this method to restrict a user in a supergroup. -The bot must be an administrator in the supergroup for this to work -and must have the appropriate admin rights. Pass True for all boolean parameters -to lift restrictions from a user. Returns True on success. +Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#restrictchatmember +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#restrictchatmember | Param | Type | Description | | --- | --- | --- | @@ -625,13 +604,10 @@ to lift restrictions from a user. Returns True on success. ### telegramBot.promoteChatMember(chatId, userId, [options]) ⇒ Promise -Use this method to promote or demote a user in a supergroup or a channel. -The bot must be an administrator in the chat for this to work -and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. -Returns True on success. +Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#promotechatmember +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#promotechatmember | Param | Type | Description | | --- | --- | --- | @@ -642,44 +618,82 @@ Returns True on success. ### telegramBot.setChatAdministratorCustomTitle(chatId, userId, customTitle, [options]) ⇒ Promise -Use this method to set a custom title for an administrator in a supergroup promoted by the bot. -Returns True on success. +Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setchatadministratorcustomtitle +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setchatadministratorcustomtitle | Param | Type | Description | | --- | --- | --- | -| chatId | Integer or String \| String | Unique identifier for the target chat or username of the target supergroup | -| userId | Integer | Unique identifier of the target user | +| chatId | Number \| String | Unique identifier for the message recipient | +| userId | Number | Unique identifier of the target user | | customTitle | String | New custom title for the administrator; 0-16 characters, emoji are not allowed | | [options] | Object | Additional Telegram query options | -### telegramBot.setChatPermissions(chatId, ChatPermissions, [options]) ⇒ Promise -Use this method to set default chat permissions for all members. The bot must be an administrator -in the group or a supergroup for this to work and must have the can_restrict_members admin rights. -Returns True on success. +### telegramBot.setChatPermissions(chatId, chatPermissions, [options]) ⇒ Promise +Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setchatpermissions +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setchatpermissions | Param | Type | Description | | --- | --- | --- | -| chatId | Integer or String \| String | Unique identifier for the target chat or username of the target supergroup | -| ChatPermissions | Object | New default chat permissions | +| chatId | Number \| String | Unique identifier for the message recipient | +| chatPermissions | Array | New default chat permissions | | [options] | Object | Additional Telegram query options | ### telegramBot.exportChatInviteLink(chatId, [options]) ⇒ Promise -Use this method to export an invite link to a supergroup or a channel. -The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. -Returns exported invite link as String on success. +Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#exportchatinvitelink +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#exportchatinvitelink + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number \| String | Unique identifier for the target chat or username of the target supergroup | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.createChatInviteLink(chatId, [options]) ⇒ Object +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. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Object - ChatInviteLink +**See**: https://core.telegram.org/bots/api#createchatinvitelink + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number \| String | Unique identifier for the target chat or username of the target supergroup | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.editChatInviteLink(chatId, inviteLink, [options]) ⇒ Object +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. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Object - ChatInviteLink +**See**: https://core.telegram.org/bots/api#editchatinvitelink + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number \| String | Unique identifier for the target chat or username of the target supergroup | +| inviteLink | String | Text with the invite link to edit | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.revokeChatInviteLink(chatId, [options]) ⇒ Object +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. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Object - ChatInviteLink +**See**: https://core.telegram.org/bots/api#revokechatinvitelink | Param | Type | Description | | --- | --- | --- | @@ -689,12 +703,10 @@ Returns exported invite link as String on success. ### telegramBot.setChatPhoto(chatId, photo, [options], [fileOptions]) ⇒ Promise -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. -Returns True on success. +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. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setchatphoto +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setchatphoto | Param | Type | Description | | --- | --- | --- | @@ -706,12 +718,10 @@ Returns True on success. ### telegramBot.deleteChatPhoto(chatId, [options]) ⇒ Promise -Use this method to delete a chat photo. 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. -Returns True on success. +Use this method to delete a chat photo. 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. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#deletechatphoto +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#deletechatphoto | Param | Type | Description | | --- | --- | --- | @@ -721,12 +731,10 @@ Returns True on success. ### telegramBot.setChatTitle(chatId, title, [options]) ⇒ Promise -Use this method to change the title of a chat. Titles 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. -Returns True on success. +Use this method to change the title of a chat. Titles 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. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setchattitle +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setchattitle | Param | Type | Description | | --- | --- | --- | @@ -737,12 +745,10 @@ Returns True on success. ### telegramBot.setChatDescription(chatId, description, [options]) ⇒ Promise -Use this method to change the description of a supergroup or a channel. -The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. -Returns True on success. +Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setchatdescription +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setchatdescription | Param | Type | Description | | --- | --- | --- | @@ -753,12 +759,10 @@ Returns True on success. ### telegramBot.pinChatMessage(chatId, messageId, [options]) ⇒ Promise -Use this method to pin a message in a supergroup. -The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. -Returns True on success. +Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#pinchatmessage +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#pinchatmessage | Param | Type | Description | | --- | --- | --- | @@ -769,12 +773,10 @@ Returns True on success. ### telegramBot.unpinChatMessage(chatId, [options]) ⇒ Promise -Use this method to unpin a message from 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. -Returns True on success. +Use this method to unpin a message in a supergroup chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#unpinchatmessage +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#unpinchatmessage | Param | Type | Description | | --- | --- | --- | @@ -784,12 +786,10 @@ Returns True on success. ### telegramBot.unpinAllChatMessages(chatId, [options]) ⇒ Promise -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. -Returns True on success. +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. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#unpinallchatmessages +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#unpinallchatmessages | Param | Type | Description | | --- | --- | --- | @@ -799,61 +799,48 @@ Returns True on success. ### telegramBot.answerCallbackQuery(callbackQueryId, [options]) ⇒ Promise -Use this method to send answers to callback queries sent from -inline keyboards. The answer will be displayed to the user as -a notification at the top of the chat screen or as an alert. -On success, True is returned. +Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. This method has **older, compatible signatures ([1][answerCallbackQuery-v0.27.1])([2][answerCallbackQuery-v0.29.0])** that are being deprecated. -This method has **older, compatible signatures ([1][answerCallbackQuery-v0.27.1])([2][answerCallbackQuery-v0.29.0])** -that are being deprecated. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#answercallbackquery +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#answercallbackquery | Param | Type | Description | | --- | --- | --- | | callbackQueryId | String | Unique identifier for the query to be answered | | [options] | Object | Additional Telegram query options | - - -### telegramBot.getMyCommands([options]) ⇒ Promise -Use this method to get the current list of the bot's commands -Returns True on success.Returns Array of BotCommand on success. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getmycommands - -| Param | Type | Description | -| --- | --- | --- | -| [options] | Object | Additional Telegram query options | - ### telegramBot.setMyCommands(commands, [options]) ⇒ Promise -Use this method to change the list of the bot's commands. -Returns True on success. +Returns True on success. Use this method to change the list of the bot's commands. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setmycommands +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setmycommands + +| Param | Type | Description | +| --- | --- | --- | +| commands | Array | Poll options, between 2-10 options | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.getMyCommands([options]) ⇒ Promise +Returns Array of BotCommand on success. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getmycommands | Param | Type | Description | | --- | --- | --- | -| commands | Array of BotCommand | A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. | | [options] | Object | Additional Telegram query options | ### telegramBot.editMessageText(text, [options]) ⇒ Promise -Use this method to edit text messages sent by the bot or via -the bot (for inline bots). On success, the edited Message is -returned. +Use this method to edit text messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned. Note that you must provide one of chat_id, message_id, or inline_message_id in your request. -Note that you must provide one of chat_id, message_id, or -inline_message_id in your request. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#editmessagetext +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#editmessagetext | Param | Type | Description | | --- | --- | --- | @@ -863,15 +850,10 @@ inline_message_id in your request. ### telegramBot.editMessageCaption(caption, [options]) ⇒ Promise -Use this method to edit captions of messages sent by the -bot or via the bot (for inline bots). On success, the -edited Message is returned. +Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned. Note that you must provide one of chat_id, message_id, or inline_message_id in your request. -Note that you must provide one of chat_id, message_id, or -inline_message_id in your request. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#editmessagecaption +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#editmessagecaption | Param | Type | Description | | --- | --- | --- | @@ -881,17 +863,10 @@ inline_message_id in your request. ### telegramBot.editMessageMedia(media, [options]) ⇒ Promise -Use this method to edit audio, document, photo, or video messages. -If a message is a part of a message album, then it can be edited only to a photo or a video. -Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. -Use previously uploaded file via its file_id or specify a URL. -On success, the edited Message is returned. +Use this method to edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, the edited Message is returned. Note that you must provide one of chat_id, message_id, or inline_message_id in your request. -Note that you must provide one of chat_id, message_id, or -inline_message_id in your request. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#editmessagemedia +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#editmessagemedia | Param | Type | Description | | --- | --- | --- | @@ -901,15 +876,10 @@ inline_message_id in your request. ### telegramBot.editMessageReplyMarkup(replyMarkup, [options]) ⇒ Promise -Use this method to edit only the reply markup of messages -sent by the bot or via the bot (for inline bots). -On success, the edited Message is returned. +Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned. Note that you must provide one of chat_id, message_id, or inline_message_id in your request. -Note that you must provide one of chat_id, message_id, or -inline_message_id in your request. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#editmessagetext +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#editmessagetext | Param | Type | Description | | --- | --- | --- | @@ -919,13 +889,10 @@ inline_message_id in your request. ### telegramBot.getUserProfilePhotos(userId, [options]) ⇒ Promise -Use this method to get a list of profile pictures for a user. -Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object. -This method has an [older, compatible signature][getUserProfilePhotos-v0.25.0] -that is being deprecated. +Use this method to get a list of profile pictures for a user. Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object. This method has an [older, compatible signature][getUserProfilePhotos-v0.25.0] that is being deprecated. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getuserprofilephotos +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getuserprofilephotos | Param | Type | Description | | --- | --- | --- | @@ -935,11 +902,10 @@ that is being deprecated. ### telegramBot.sendLocation(chatId, latitude, longitude, [options]) ⇒ Promise -Send location. -Use this method to send point on the map. +Send location. Use this method to send point on the map. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendlocation +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendlocation | Param | Type | Description | | --- | --- | --- | @@ -951,14 +917,10 @@ Use this method to send point on the map. ### telegramBot.editMessageLiveLocation(latitude, longitude, [options]) ⇒ Promise -Use this method to edit live location messages sent by -the bot or via the bot (for inline bots). +Use this method to edit live location messages sent by the bot or via the bot (for inline bots). Note that you must provide one of chat_id, message_id, or inline_message_id in your request. -Note that you must provide one of chat_id, message_id, or -inline_message_id in your request. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#editmessagelivelocation +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#editmessagelivelocation | Param | Type | Description | | --- | --- | --- | @@ -969,14 +931,10 @@ inline_message_id in your request. ### telegramBot.stopMessageLiveLocation([options]) ⇒ Promise -Use this method to stop updating a live location message sent by -the bot or via the bot (for inline bots) before live_period expires. +Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires. Note that you must provide one of chat_id, message_id, or inline_message_id in your request. -Note that you must provide one of chat_id, message_id, or -inline_message_id in your request. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#stopmessagelivelocation +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#stopmessagelivelocation | Param | Type | Description | | --- | --- | --- | @@ -985,11 +943,10 @@ inline_message_id in your request. ### telegramBot.sendVenue(chatId, latitude, longitude, title, address, [options]) ⇒ Promise -Send venue. -Use this method to send information about a venue. +Send venue. Use this method to send information about a venue. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendvenue +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendvenue | Param | Type | Description | | --- | --- | --- | @@ -1003,11 +960,10 @@ Use this method to send information about a venue. ### telegramBot.sendContact(chatId, phoneNumber, firstName, [options]) ⇒ Promise -Send contact. -Use this method to send phone contacts. +Send contact. Use this method to send phone contacts. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendcontact +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendcontact | Param | Type | Description | | --- | --- | --- | @@ -1019,11 +975,10 @@ Use this method to send phone contacts. ### telegramBot.sendPoll(chatId, question, pollOptions, [options]) ⇒ Promise -Send poll. -Use this method to send a native poll. +Send poll. Use this method to send a native poll. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendpoll +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendpoll | Param | Type | Description | | --- | --- | --- | @@ -1035,11 +990,10 @@ Use this method to send a native poll. ### telegramBot.stopPoll(chatId, pollId, [options]) ⇒ Promise -Stop poll. -Use this method to stop a native poll. +Stop poll. Use this method to stop a native poll. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#stoppoll +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#stoppoll | Param | Type | Description | | --- | --- | --- | @@ -1047,29 +1001,13 @@ Use this method to stop a native poll. | pollId | Number | Identifier of the original message with the poll | | [options] | Object | Additional Telegram query options | - - -### telegramBot.sendDice(chatId, [options]) ⇒ Promise -Send Dice. -Use this method to send a dice. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#senddice - -| Param | Type | Description | -| --- | --- | --- | -| chatId | Number \| String | Unique identifier for the group/channel | -| [options] | Object | Additional Telegram query options | - ### telegramBot.getFile(fileId, [options]) ⇒ Promise -Get file. -Use this method to get basic info about a file and prepare it for downloading. -Attention: link will be valid for 1 hour. +Get file. Use this method to get basic info about a file and prepare it for downloading. Attention: link will be valid for 1 hour. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getfile +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getfile | Param | Type | Description | | --- | --- | --- | @@ -1079,16 +1017,11 @@ Attention: link will be valid for 1 hour. ### telegramBot.getFileLink(fileId, [options]) ⇒ Promise -Get link for file. -Use this method to get link for file for subsequent use. -Attention: link will be valid for 1 hour. +Get link for file. Use this method to get link for file for subsequent use. Attention: link will be valid for 1 hour. This method is a sugar extension of the (getFile)[#getfilefileid] method, which returns just path to file on remote server (you will have to manually build full uri after that). -This method is a sugar extension of the (getFile)[#getfilefileid] method, -which returns just path to file on remote server (you will have to manually build full uri after that). - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: Promise - promise Promise which will have *fileURI* in resolve callback -**See**: https://core.telegram.org/bots/api#getfile +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - promise Promise which will have *fileURI* in resolve callback +**See**: https://core.telegram.org/bots/api#getfile | Param | Type | Description | | --- | --- | --- | @@ -1098,18 +1031,10 @@ which returns just path to file on remote server (you will have to manually buil ### telegramBot.getFileStream(fileId, [options]) ⇒ stream.Readable -Return a readable stream for file. +Return a readable stream for file. `fileStream.path` is the specified file ID i.e. `fileId`. `fileStream` emits event `info` passing a single argument i.e. `info` with the interface `{ uri }` where `uri` is the URI of the file on Telegram servers. This method is a sugar extension of the [getFileLink](#TelegramBot+getFileLink) method, which returns the full URI to the file on remote server. -`fileStream.path` is the specified file ID i.e. `fileId`. -`fileStream` emits event `info` passing a single argument i.e. -`info` with the interface `{ uri }` where `uri` is the URI of the -file on Telegram servers. - -This method is a sugar extension of the [getFileLink](#TelegramBot+getFileLink) method, -which returns the full URI to the file on remote server. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: stream.Readable - fileStream +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: stream.Readable - fileStream | Param | Type | Description | | --- | --- | --- | @@ -1119,13 +1044,10 @@ which returns the full URI to the file on remote server. ### telegramBot.downloadFile(fileId, downloadDir, [options]) ⇒ Promise -Downloads file in the specified folder. +Downloads file in the specified folder. This method is a sugar extension of the [getFileStream](#TelegramBot+getFileStream) method, which returns a readable file stream. -This method is a sugar extension of the [getFileStream](#TelegramBot+getFileStream) method, -which returns a readable file stream. - -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: Promise - promise Promise, which will have *filePath* of downloaded file in resolve callback +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - promise Promise, which will have *filePath* of downloaded file in resolve callback | Param | Type | Description | | --- | --- | --- | @@ -1138,7 +1060,7 @@ which returns a readable file stream. ### telegramBot.onText(regexp, callback) Register a RegExp to test against an incomming text message. -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) | Param | Type | Description | | --- | --- | --- | @@ -1150,22 +1072,26 @@ Register a RegExp to test against an incomming text message. ### telegramBot.removeTextListener(regexp) ⇒ Object Remove a listener registered with `onText()`. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: Object - deletedListener The removed reply listener if - found. This object has `regexp` and `callback` - properties. If not found, returns `null`. +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Object - deletedListener The removed reply listener if found. This object has `regexp` and `callback` properties. If not found, returns `null`. | Param | Type | Description | | --- | --- | --- | | regexp | RegExp | RegExp used previously in `onText()` | + + +### telegramBot.clearTextListeners() +Remove all listeners registered with `onText()`. + +**Kind**: instance method of [TelegramBot](#TelegramBot) ### telegramBot.onReplyToMessage(chatId, messageId, callback) ⇒ Number Register a reply to wait for a message response. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: Number - id The ID of the inserted reply listener. +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Number - id The ID of the inserted reply listener. | Param | Type | Description | | --- | --- | --- | @@ -1178,38 +1104,26 @@ Register a reply to wait for a message response. ### telegramBot.removeReplyListener(replyListenerId) ⇒ Object Removes a reply that has been prev. registered for a message response. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**Returns**: Object - deletedListener The removed reply listener if - found. This object has `id`, `chatId`, `messageId` and `callback` - properties. If not found, returns `null`. +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Object - deletedListener The removed reply listener if found. This object has `id`, `chatId`, `messageId` and `callback` properties. If not found, returns `null`. | Param | Type | Description | | --- | --- | --- | | replyListenerId | Number | The ID of the reply listener. | - - -### telegramBot.clearTextListeners() -Remove all listeners registered with `onText()`. - -**Kind**: instance method of [TelegramBot](#TelegramBot) - ### telegramBot.clearReplyListeners() -Removes all replies that have been previously registered for a message response. - -**Kind**: instance method of [TelegramBot](#TelegramBot) +Removes all replies that have been prev. registered for a message response. +**Kind**: instance method of [TelegramBot](#TelegramBot) ### telegramBot.getChat(chatId, [options]) ⇒ Promise -Use this method to get up to date information about the chat -(current name of the user for one-on-one conversations, current -username of a user, group or channel, etc.). +Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getchat +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getchat | Param | Type | Description | | --- | --- | --- | @@ -1221,8 +1135,8 @@ username of a user, group or channel, etc.). ### telegramBot.getChatAdministrators(chatId, [options]) ⇒ Promise Returns the administrators in a chat in form of an Array of `ChatMember` objects. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getchatadministrators +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getchatadministrators | Param | Type | Description | | --- | --- | --- | @@ -1234,8 +1148,8 @@ Returns the administrators in a chat in form of an Array of `ChatMember` objects ### telegramBot.getChatMembersCount(chatId, [options]) ⇒ Promise Use this method to get the number of members in a chat. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getchatmemberscount +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getchatmemberscount | Param | Type | Description | | --- | --- | --- | @@ -1247,8 +1161,8 @@ Use this method to get the number of members in a chat. ### telegramBot.getChatMember(chatId, userId, [options]) ⇒ Promise Use this method to get information about a member of a chat. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getchatmember +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getchatmember | Param | Type | Description | | --- | --- | --- | @@ -1261,8 +1175,8 @@ Use this method to get information about a member of a chat. ### telegramBot.leaveChat(chatId, [options]) ⇒ Promise Leave a group, supergroup or channel. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#leavechat +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#leavechat | Param | Type | Description | | --- | --- | --- | @@ -1274,8 +1188,8 @@ Leave a group, supergroup or channel. ### telegramBot.setChatStickerSet(chatId, stickerSetName, [options]) ⇒ Promise Use this method to set a new group sticker set for a supergroup. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setchatstickerset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setchatstickerset | Param | Type | Description | | --- | --- | --- | @@ -1288,8 +1202,8 @@ Use this method to set a new group sticker set for a supergroup. ### telegramBot.deleteChatStickerSet(chatId, [options]) ⇒ Promise Use this method to delete a group sticker set from a supergroup. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#deletechatstickerset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#deletechatstickerset | Param | Type | Description | | --- | --- | --- | @@ -1301,8 +1215,8 @@ Use this method to delete a group sticker set from a supergroup. ### telegramBot.sendGame(chatId, gameShortName, [options]) ⇒ Promise Use this method to send a game. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendgame +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendgame | Param | Type | Description | | --- | --- | --- | @@ -1315,8 +1229,8 @@ Use this method to send a game. ### telegramBot.setGameScore(userId, score, [options]) ⇒ Promise Use this method to set the score of the specified user in a game. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setgamescore +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setgamescore | Param | Type | Description | | --- | --- | --- | @@ -1329,8 +1243,8 @@ Use this method to set the score of the specified user in a game. ### telegramBot.getGameHighScores(userId, [options]) ⇒ Promise Use this method to get data for high score table. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getgamehighscores +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getgamehighscores | Param | Type | Description | | --- | --- | --- | @@ -1342,8 +1256,8 @@ Use this method to get data for high score table. ### telegramBot.deleteMessage(chatId, messageId, [options]) ⇒ Promise Use this method to delete a message. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#deletemessage +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#deletemessage | Param | Type | Description | | --- | --- | --- | @@ -1354,11 +1268,10 @@ Use this method to delete a message. ### telegramBot.sendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, [options]) ⇒ Promise -Send invoice. -Use this method to send an invoice. +Send invoice. Use this method to send an invoice. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#sendinvoice +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendinvoice | Param | Type | Description | | --- | --- | --- | @@ -1375,11 +1288,10 @@ Use this method to send an invoice. ### telegramBot.answerShippingQuery(shippingQueryId, ok, [options]) ⇒ Promise -Answer shipping query.. -Use this method to reply to shipping queries. +Answer shipping query.. Use this method to reply to shipping queries. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#answershippingquery +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#answershippingquery | Param | Type | Description | | --- | --- | --- | @@ -1390,11 +1302,10 @@ Use this method to reply to shipping queries. ### telegramBot.answerPreCheckoutQuery(preCheckoutQueryId, ok, [options]) ⇒ Promise -Answer pre-checkout query. -Use this method to confirm shipping of a product. +Answer pre-checkout query. Use this method to confirm shipping of a product. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#answerprecheckoutquery +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#answerprecheckoutquery | Param | Type | Description | | --- | --- | --- | @@ -1407,8 +1318,8 @@ Use this method to confirm shipping of a product. ### telegramBot.getStickerSet(name, [options]) ⇒ Promise Use this method to get a sticker set. On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#getstickerset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#getstickerset | Param | Type | Description | | --- | --- | --- | @@ -1418,11 +1329,10 @@ Use this method to get a sticker set. On success, a [StickerSet](https://core.te ### telegramBot.uploadStickerFile(userId, pngSticker, [options], [fileOptions]) ⇒ Promise -Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple -times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on success. +Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#uploadstickerfile +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#uploadstickerfile | Param | Type | Description | | --- | --- | --- | @@ -1434,12 +1344,10 @@ times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on ### telegramBot.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions]) ⇒ Promise -Use this method to create new sticker set owned by a user. -The bot will be able to edit the created sticker set. -Returns True on success. +Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#createnewstickerset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#createnewstickerset **Todo** - [ ] Add tests for this method! @@ -1458,11 +1366,10 @@ Returns True on success. ### telegramBot.addStickerToSet(userId, name, pngSticker, emojis, [options], [fileOptions]) ⇒ Promise -Use this method to add a new sticker to a set created by the bot. -Returns True on success. +Use this method to add a new sticker to a set created by the bot. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#addstickertoset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#addstickertoset **Todo** - [ ] Add tests for this method! @@ -1480,11 +1387,10 @@ Returns True on success. ### telegramBot.setStickerPositionInSet(sticker, position, [options]) ⇒ Promise -Use this method to move a sticker in a set created by the bot to a specific position. -Returns True on success. +Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#setstickerpositioninset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setstickerpositioninset **Todo** - [ ] Add tests for this method! @@ -1499,11 +1405,10 @@ Returns True on success. ### telegramBot.deleteStickerFromSet(sticker, [options]) ⇒ Promise -Use this method to delete a sticker from a set created by the bot. -Returns True on success. +Use this method to delete a sticker from a set created by the bot. Returns True on success. -**Kind**: instance method of [TelegramBot](#TelegramBot) -**See**: https://core.telegram.org/bots/api#deletestickerfromset +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#deletestickerfromset **Todo** - [ ] Add tests for this method! @@ -1517,14 +1422,9 @@ Returns True on success. ### telegramBot.sendMediaGroup(chatId, media, [options]) ⇒ Promise -Use this method to send a group of photos or videos as an album. -On success, an array of the sent [Messages](https://core.telegram.org/bots/api#message) -is returned. +Use this method to send a group of photos or videos as an album. On success, an array of the sent [Messages](https://core.telegram.org/bots/api#message) is returned. If you wish to [specify file options](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files), add a `fileOptions` property to the target input in `media`. -If you wish to [specify file options](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files), -add a `fileOptions` property to the target input in `media`. - -**Kind**: instance method of [TelegramBot](#TelegramBot) +**Kind**: instance method of [TelegramBot](#TelegramBot) **See** - https://core.telegram.org/bots/api#sendmediagroup @@ -1542,36 +1442,34 @@ add a `fileOptions` property to the target input in `media`. ### TelegramBot.errors : Object The different errors the library uses. -**Kind**: static property of [TelegramBot](#TelegramBot) +**Kind**: static property of [TelegramBot](#TelegramBot) -### TelegramBot.messageTypes : Array.<String> +### TelegramBot.messageTypes : [ 'Array' ].<String> The types of message updates the library handles. -**Kind**: static property of [TelegramBot](#TelegramBot) +**Kind**: static property of [TelegramBot](#TelegramBot) ### TelegramBot.Promise -Change Promise library used internally, for all existing and new -instances. +Change Promise library used internally, for all existing and new instances. -**Kind**: static property of [TelegramBot](#TelegramBot) +**Kind**: static property of [TelegramBot](#TelegramBot) | Param | Type | | --- | --- | -| customPromise | function | +| customPromise | function | -**Example** +**Example** ```js -const TelegramBot = require('node-telegram-bot-api'); -TelegramBot.Promise = myPromise; +const TelegramBot = require('node-telegram-bot-api'); TelegramBot.Promise = myPromise; ``` -* * * - - -[usage-sending-files-performance]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/usage.md#sending-files-performance -[setWebHook-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#telegrambotsetwebhookurl-cert -[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates -[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos -[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery -[answerCallbackQuery-v0.29.0]:https://github.com/yagop/node-telegram-bot-api/blob/v0.29.0/doc/api.md#TelegramBot+answerCallbackQuery +* * * + + +[usage-sending-files-performance]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/usage.md#sending-files-performance +[setWebHook-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#telegrambotsetwebhookurl-cert +[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates +[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos +[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery +[answerCallbackQuery-v0.29.0]:https://github.com/yagop/node-telegram-bot-api/blob/v0.29.0/doc/api.md#TelegramBot+answerCallbackQuery diff --git a/package.json b/package.json index 50234ca..6377c0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-telegram-bot-api", - "version": "0.51.0", + "version": "0.52.0", "description": "Telegram Bot API", "main": "./index.js", "directories": { diff --git a/src/telegram.js b/src/telegram.js index f5902da..3063d2c 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -48,6 +48,12 @@ const _messageTypes = [ 'video', 'video_note', 'voice', + 'voice_chat_started', + 'voice_chat_ended', + 'voice_chat_participants_invited', + 'message_auto_delete_timer_changed', + 'chat_invite_link', + 'chat_member_updated' ]; const _deprecatedMessageTypes = [ 'new_chat_participant', 'left_chat_participant' @@ -615,6 +621,8 @@ class TelegramBot extends EventEmitter { const preCheckoutQuery = update.pre_checkout_query; const poll = update.poll; const pollAnswer = update.poll_answer; + const chatMember = update.chat_member; + const myChatMember = update.my_chat_member; if (message) { debug('Process Update message %j', message); @@ -698,6 +706,12 @@ class TelegramBot extends EventEmitter { } else if (pollAnswer) { debug('Process Update poll_answer %j', 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 }); } + /** + * 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. * 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 }); } - /** - * 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. - * Returns True on success. - * - * @param {Number|String} chatId Unique identifier for the message recipient - * @param {Object} [options] Additional Telegram query options - * @return {Promise} - * @see https://core.telegram.org/bots/api#unpinallchatmessages - */ + /** + * 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. + * Returns True on success. + * + * @param {Number|String} chatId Unique identifier for the message recipient + * @param {Object} [options] Additional Telegram query options + * @return {Promise} + * @see https://core.telegram.org/bots/api#unpinallchatmessages + */ unpinAllChatMessages(chatId, form = {}) { form.chat_id = chatId; return this._request('unpinAllChatMessages', { form }); diff --git a/test/telegram.js b/test/telegram.js index 55a460b..688eeea 100644 --- a/test/telegram.js +++ b/test/telegram.js @@ -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() { this.timeout(timeout); before(function before() {