2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-22 01:47:25 +00:00

Add new method sendDice, getMyCommands, setMyCommands and more (#796)

* 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
This commit is contained in:
Daniel Pérez Fernández 2020-05-12 06:01:30 +02:00 committed by GitHub
parent c6a0eedc9a
commit 1bae9c2964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 447 additions and 177 deletions

View File

@ -3,7 +3,29 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [0.40.0][0.40.0] - 2019-10-15
## [0.50.0][0.50.0] - 2020-05-2020
1. Support Bot API v4.8: (by @danielperez9430)
* Add methods: *sendDice()*
1. Support Bot API v4.7: (by @danielperez9430)
* Add methods: *getMyCommands()*,*setMyCommands()*
1. Support Bot API v4.5: (by @danielperez9430)
* Add methods: *setChatAdministratorCustomTitle()*
1. Support Bot API v4.4: (by @danielperez9430)
* Add methods: *setChatPermissions()*
1. Support for poll_answer (by @JieJiSS)
Changed: (by @danielperez9430)
* New message type: *dice*
* Fix Bugs in tests
New Test: (by @danielperez9430)
* sendDice
* getMyCommands
* setMyCommands
* setChatAdministratorCustomTitle
* setChatPermissions
## [0.40.0][0.40.0] - 2019-05-04
Added:

View File

@ -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.4.4.0-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![Bot API](https://img.shields.io/badge/Bot%20API-v.4.8.0-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)

View File

@ -7,8 +7,8 @@
## 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)
@ -43,6 +43,8 @@ TelegramBot
* [.unbanChatMember(chatId, userId, [options])](#TelegramBot+unbanChatMember) ⇒ <code>Promise</code>
* [.restrictChatMember(chatId, userId, [options])](#TelegramBot+restrictChatMember) ⇒ <code>Promise</code>
* [.promoteChatMember(chatId, userId, [options])](#TelegramBot+promoteChatMember) ⇒ <code>Promise</code>
* [.setChatAdministratorCustomTitle(chatId, userId, customTitle, [options])](#TelegramBot+setChatAdministratorCustomTitle) ⇒ <code>Promise</code>
* [.setChatPermissions(chatId, ChatPermissions, [options])](#TelegramBot+setChatPermissions) ⇒ <code>Promise</code>
* [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code>
* [.setChatPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+setChatPhoto) ⇒ <code>Promise</code>
* [.deleteChatPhoto(chatId, [options])](#TelegramBot+deleteChatPhoto) ⇒ <code>Promise</code>
@ -51,6 +53,8 @@ TelegramBot
* [.pinChatMessage(chatId, messageId, [options])](#TelegramBot+pinChatMessage) ⇒ <code>Promise</code>
* [.unpinChatMessage(chatId, [options])](#TelegramBot+unpinChatMessage) ⇒ <code>Promise</code>
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ <code>Promise</code>
* [.editMessageText(text, [options])](#TelegramBot+editMessageText) ⇒ <code>Promise</code>
* [.editMessageCaption(caption, [options])](#TelegramBot+editMessageCaption) ⇒ <code>Promise</code>
* [.editMessageMedia(media, [options])](#TelegramBot+editMessageMedia) ⇒ <code>Promise</code>
@ -63,6 +67,7 @@ TelegramBot
* [.sendContact(chatId, phoneNumber, firstName, [options])](#TelegramBot+sendContact) ⇒ <code>Promise</code>
* [.sendPoll(chatId, question, pollOptions, [options])](#TelegramBot+sendPoll) ⇒ <code>Promise</code>
* [.stopPoll(chatId, pollId, [options])](#TelegramBot+stopPoll) ⇒ <code>Promise</code>
* [.sendDice(chatId, [options])](#TelegramBot+sendDice) ⇒ <code>Promise</code>
* [.getFile(fileId, [options])](#TelegramBot+getFile) ⇒ <code>Promise</code>
* [.getFileLink(fileId, [options])](#TelegramBot+getFileLink) ⇒ <code>Promise</code>
* [.getFileStream(fileId, [options])](#TelegramBot+getFileStream) ⇒ <code>stream.Readable</code>
@ -136,7 +141,7 @@ Emits `message` when a message arrives.
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 [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- [Available events](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events)
@ -145,8 +150,8 @@ This is the usual `emitter.on()` method.
| Param | Type |
| --- | --- |
| event | <code>String</code> |
| listener | <code>function</code> |
| event | <code>String</code> |
| listener | <code>function</code> |
<a name="TelegramBot+startPolling"></a>
@ -154,7 +159,7 @@ This is the usual `emitter.on()` method.
Start polling.
Rejects returned promise if a WebHook is being used by this instance.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
| Param | Type | Default | Description |
| --- | --- | --- | --- |
@ -168,11 +173,11 @@ Rejects returned promise if a WebHook is being used by this instance.
Alias of `TelegramBot#startPolling()`. This is **deprecated**.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
| Param | Type |
| --- | --- |
| [options] | <code>Object</code> |
| [options] | <code>Object</code> |
<a name="TelegramBot+stopPolling"></a>
@ -181,7 +186,7 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
| Param | Type | Description |
| --- | --- | --- |
@ -194,7 +199,7 @@ Returning the promise of the last polling request is **deprecated**.
### telegramBot.isPolling() ⇒ <code>Boolean</code>
Return true if polling. Otherwise, false.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
<a name="TelegramBot+openWebHook"></a>
### telegramBot.openWebHook() ⇒ <code>Promise</code>
@ -202,29 +207,29 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
<a name="TelegramBot+closeWebHook"></a>
### telegramBot.closeWebHook() ⇒ <code>Promise</code>
Close webhook after closing all current connections.
Multiple invocations do nothing if webhook is already closed.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - promise
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - promise
<a name="TelegramBot+hasOpenWebHook"></a>
### telegramBot.hasOpenWebHook() ⇒ <code>Boolean</code>
Return true if using webhook and it is open i.e. accepts connections.
Otherwise, false.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
<a name="TelegramBot+getMe"></a>
### telegramBot.getMe([options]) ⇒ <code>Promise</code>
Returns basic information about the bot in form of a `User` object.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getme
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getme
| Param | Type | Description |
| --- | --- | --- |
@ -237,7 +242,7 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#setwebhook
@ -257,8 +262,8 @@ that is being deprecated.
Use this method to remove webhook integration if you decide to
switch back to getUpdates. Returns True on success.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletewebhook
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletewebhook
| Param | Type | Description |
| --- | --- | --- |
@ -272,8 +277,8 @@ On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookin
If the bot is using getUpdates, will return an object with the
url field empty.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getwebhookinfo
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getwebhookinfo
| Param | Type | Description |
| --- | --- | --- |
@ -286,8 +291,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getupdates
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getupdates
| Param | Type | Description |
| --- | --- | --- |
@ -300,20 +305,20 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#update
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#update
| Param | Type |
| --- | --- |
| update | <code>Object</code> |
| update | <code>Object</code> |
<a name="TelegramBot+sendMessage"></a>
### telegramBot.sendMessage(chatId, text, [options]) ⇒ <code>Promise</code>
Send text message.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendmessage
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendmessage
| Param | Type | Description |
| --- | --- | --- |
@ -326,8 +331,8 @@ Send text message.
### telegramBot.answerInlineQuery(inlineQueryId, results, [options]) ⇒ <code>Promise</code>
Send answers to an inline query.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answerinlinequery
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answerinlinequery
| Param | Type | Description |
| --- | --- | --- |
@ -340,7 +345,7 @@ Send answers to an inline query.
### telegramBot.forwardMessage(chatId, fromChatId, messageId, [options]) ⇒ <code>Promise</code>
Forward messages of any kind.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
| Param | Type | Description |
| --- | --- | --- |
@ -354,7 +359,7 @@ Forward messages of any kind.
### telegramBot.sendPhoto(chatId, photo, [options], [fileOptions]) ⇒ <code>Promise</code>
Send photo
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendphoto
@ -373,7 +378,7 @@ Send photo
### telegramBot.sendAudio(chatId, audio, [options], [fileOptions]) ⇒ <code>Promise</code>
Send audio
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendaudio
@ -392,7 +397,7 @@ Send audio
### telegramBot.sendDocument(chatId, doc, [options], [fileOptions]) ⇒ <code>Promise</code>
Send Document
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendDocument
@ -411,8 +416,8 @@ Send Document
### telegramBot.sendSticker(chatId, sticker, [options], [fileOptions]) ⇒ <code>Promise</code>
Send .webp stickers.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendsticker
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendsticker
| Param | Type | Description |
| --- | --- | --- |
@ -426,7 +431,7 @@ Send .webp stickers.
### telegramBot.sendVideo(chatId, video, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendvideo
@ -445,7 +450,7 @@ Use this method to send video files, Telegram clients support mp4 videos (other
### telegramBot.sendAnimation(chatId, animation, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendanimation
@ -464,8 +469,8 @@ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without s
### telegramBot.sendVideoNote(chatId, videoNote, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to send rounded square videos of upto 1 minute long.
**Kind**: instance method of [<code>TelegramBot</code>](#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 [<code>TelegramBot</code>](#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
@ -484,7 +489,7 @@ Use this method to send rounded square videos of upto 1 minute long.
### telegramBot.sendVoice(chatId, voice, [options], [fileOptions]) ⇒ <code>Promise</code>
Send voice
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendvoice
@ -507,8 +512,8 @@ Send chat action.
`record_audio` or `upload_audio` for audio files, `upload_document` for general files,
`find_location` for location data.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendchataction
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendchataction
| Param | Type | Description |
| --- | --- | --- |
@ -525,8 +530,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#kickchatmember
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#kickchatmember
| Param | Type | Description |
| --- | --- | --- |
@ -542,8 +547,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#unbanchatmember
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#unbanchatmember
| Param | Type | Description |
| --- | --- | --- |
@ -559,8 +564,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#restrictchatmember
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#restrictchatmember
| Param | Type | Description |
| --- | --- | --- |
@ -576,8 +581,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#promotechatmember
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#promotechatmember
| Param | Type | Description |
| --- | --- | --- |
@ -585,6 +590,38 @@ Returns True on success.
| userId | <code>Number</code> | |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+setChatAdministratorCustomTitle"></a>
### telegramBot.setChatAdministratorCustomTitle(chatId, userId, customTitle, [options]) ⇒ <code>Promise</code>
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatadministratorcustomtitle
| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Integer or String</code> \| <code>String</code> | Unique identifier for the target chat or username of the target supergroup |
| userId | <code>Integer</code> | Unique identifier of the target user |
| customTitle | <code>String</code> | New custom title for the administrator; 0-16 characters, emoji are not allowed |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+setChatPermissions"></a>
### telegramBot.setChatPermissions(chatId, ChatPermissions, [options]) ⇒ <code>Promise</code>
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatpermissions
| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Integer or String</code> \| <code>String</code> | Unique identifier for the target chat or username of the target supergroup |
| ChatPermissions | <code>Object</code> | New default chat permissions |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+exportChatInviteLink"></a>
### telegramBot.exportChatInviteLink(chatId, [options]) ⇒ <code>Promise</code>
@ -592,8 +629,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#exportchatinvitelink
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#exportchatinvitelink
| Param | Type | Description |
| --- | --- | --- |
@ -607,8 +644,8 @@ Use this method to set a new profile photo for the chat. Photos can't be changed
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatphoto
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatphoto
| Param | Type | Description |
| --- | --- | --- |
@ -624,8 +661,8 @@ Use this method to delete a chat photo. Photos can't be changed for private 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletechatphoto
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletechatphoto
| Param | Type | Description |
| --- | --- | --- |
@ -639,8 +676,8 @@ Use this method to change the title of a chat. Titles can't be changed for priva
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchattitle
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchattitle
| Param | Type | Description |
| --- | --- | --- |
@ -655,8 +692,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatdescription
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatdescription
| Param | Type | Description |
| --- | --- | --- |
@ -671,8 +708,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#pinchatmessage
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#pinchatmessage
| Param | Type | Description |
| --- | --- | --- |
@ -687,8 +724,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#unpinchatmessage
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#unpinchatmessage
| Param | Type | Description |
| --- | --- | --- |
@ -706,14 +743,41 @@ 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.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answercallbackquery
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answercallbackquery
| Param | Type | Description |
| --- | --- | --- |
| callbackQueryId | <code>String</code> | Unique identifier for the query to be answered |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+getMyCommands"></a>
### telegramBot.getMyCommands([options]) ⇒ <code>Promise</code>
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getmycommands
| Param | Type | Description |
| --- | --- | --- |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+setMyCommands"></a>
### telegramBot.setMyCommands(commands, [options]) ⇒ <code>Promise</code>
Use this method to change the list of the bot's commands.
Returns True on success.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setmycommands
| Param | Type | Description |
| --- | --- | --- |
| commands | <code>Array of BotCommand</code> | 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] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+editMessageText"></a>
### telegramBot.editMessageText(text, [options]) ⇒ <code>Promise</code>
@ -724,8 +788,8 @@ returned.
Note that you must provide one of chat_id, message_id, or
inline_message_id in your request.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagetext
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagetext
| Param | Type | Description |
| --- | --- | --- |
@ -742,8 +806,8 @@ edited Message is returned.
Note that you must provide one of chat_id, message_id, or
inline_message_id in your request.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagecaption
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagecaption
| Param | Type | Description |
| --- | --- | --- |
@ -762,8 +826,8 @@ 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.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagemedia
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagemedia
| Param | Type | Description |
| --- | --- | --- |
@ -780,8 +844,8 @@ 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.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagetext
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagetext
| Param | Type | Description |
| --- | --- | --- |
@ -796,8 +860,8 @@ Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephot
This method has an [older, compatible signature][getUserProfilePhotos-v0.25.0]
that is being deprecated.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getuserprofilephotos
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getuserprofilephotos
| Param | Type | Description |
| --- | --- | --- |
@ -810,8 +874,8 @@ that is being deprecated.
Send location.
Use this method to send point on the map.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendlocation
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendlocation
| Param | Type | Description |
| --- | --- | --- |
@ -829,8 +893,8 @@ 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.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagelivelocation
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#editmessagelivelocation
| Param | Type | Description |
| --- | --- | --- |
@ -847,8 +911,8 @@ 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.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#stopmessagelivelocation
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#stopmessagelivelocation
| Param | Type | Description |
| --- | --- | --- |
@ -860,8 +924,8 @@ inline_message_id in your request.
Send venue.
Use this method to send information about a venue.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendvenue
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendvenue
| Param | Type | Description |
| --- | --- | --- |
@ -878,8 +942,8 @@ Use this method to send information about a venue.
Send contact.
Use this method to send phone contacts.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendcontact
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendcontact
| Param | Type | Description |
| --- | --- | --- |
@ -894,8 +958,8 @@ Use this method to send phone contacts.
Send poll.
Use this method to send a native poll.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendpoll
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendpoll
| Param | Type | Description |
| --- | --- | --- |
@ -910,8 +974,8 @@ Use this method to send a native poll.
Stop poll.
Use this method to stop a native poll.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#stoppoll
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#stoppoll
| Param | Type | Description |
| --- | --- | --- |
@ -919,6 +983,20 @@ Use this method to stop a native poll.
| pollId | <code>Number</code> | Identifier of the original message with the poll |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+sendDice"></a>
### telegramBot.sendDice(chatId, [options]) ⇒ <code>Promise</code>
Send Dice.
Use this method to send a dice.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#senddice
| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the group/channel |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+getFile"></a>
### telegramBot.getFile(fileId, [options]) ⇒ <code>Promise</code>
@ -926,8 +1004,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getfile
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getfile
| Param | Type | Description |
| --- | --- | --- |
@ -944,9 +1022,9 @@ 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).
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - promise Promise which will have *fileURI* in resolve callback
**See**: https://core.telegram.org/bots/api#getfile
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - promise Promise which will have *fileURI* in resolve callback
**See**: https://core.telegram.org/bots/api#getfile
| Param | Type | Description |
| --- | --- | --- |
@ -966,8 +1044,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>stream.Readable</code> - fileStream
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>stream.Readable</code> - fileStream
| Param | Type | Description |
| --- | --- | --- |
@ -982,8 +1060,8 @@ Downloads file in the specified folder.
This method is a sugar extension of the [getFileStream](#TelegramBot+getFileStream) method,
which returns a readable file stream.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - promise Promise, which will have *filePath* of downloaded file in resolve callback
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - promise Promise, which will have *filePath* of downloaded file in resolve callback
| Param | Type | Description |
| --- | --- | --- |
@ -996,7 +1074,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 [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
| Param | Type | Description |
| --- | --- | --- |
@ -1008,10 +1086,10 @@ Register a RegExp to test against an incomming text message.
### telegramBot.removeTextListener(regexp) ⇒ <code>Object</code>
Remove a listener registered with `onText()`.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Object</code> - deletedListener The removed reply listener if
found. This object has `regexp` and `callback`
properties. If not found, returns `null`.
properties. If not found, returns `null`.
| Param | Type | Description |
| --- | --- | --- |
@ -1022,8 +1100,8 @@ Remove a listener registered with `onText()`.
### telegramBot.onReplyToMessage(chatId, messageId, callback) ⇒ <code>Number</code>
Register a reply to wait for a message response.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Number</code> - id The ID of the inserted reply listener.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Number</code> - id The ID of the inserted reply listener.
| Param | Type | Description |
| --- | --- | --- |
@ -1036,10 +1114,10 @@ Register a reply to wait for a message response.
### telegramBot.removeReplyListener(replyListenerId) ⇒ <code>Object</code>
Removes a reply that has been prev. registered for a message response.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Object</code> - deletedListener The removed reply listener if
found. This object has `id`, `chatId`, `messageId` and `callback`
properties. If not found, returns `null`.
properties. If not found, returns `null`.
| Param | Type | Description |
| --- | --- | --- |
@ -1052,8 +1130,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchat
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchat
| Param | Type | Description |
| --- | --- | --- |
@ -1065,8 +1143,8 @@ username of a user, group or channel, etc.).
### telegramBot.getChatAdministrators(chatId, [options]) ⇒ <code>Promise</code>
Returns the administrators in a chat in form of an Array of `ChatMember` objects.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchatadministrators
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchatadministrators
| Param | Type | Description |
| --- | --- | --- |
@ -1078,8 +1156,8 @@ Returns the administrators in a chat in form of an Array of `ChatMember` objects
### telegramBot.getChatMembersCount(chatId, [options]) ⇒ <code>Promise</code>
Use this method to get the number of members in a chat.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchatmemberscount
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchatmemberscount
| Param | Type | Description |
| --- | --- | --- |
@ -1091,8 +1169,8 @@ Use this method to get the number of members in a chat.
### telegramBot.getChatMember(chatId, userId, [options]) ⇒ <code>Promise</code>
Use this method to get information about a member of a chat.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchatmember
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getchatmember
| Param | Type | Description |
| --- | --- | --- |
@ -1105,8 +1183,8 @@ Use this method to get information about a member of a chat.
### telegramBot.leaveChat(chatId, [options]) ⇒ <code>Promise</code>
Leave a group, supergroup or channel.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#leavechat
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#leavechat
| Param | Type | Description |
| --- | --- | --- |
@ -1118,8 +1196,8 @@ Leave a group, supergroup or channel.
### telegramBot.setChatStickerSet(chatId, stickerSetName, [options]) ⇒ <code>Promise</code>
Use this method to set a new group sticker set for a supergroup.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatstickerset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setchatstickerset
| Param | Type | Description |
| --- | --- | --- |
@ -1132,8 +1210,8 @@ Use this method to set a new group sticker set for a supergroup.
### telegramBot.deleteChatStickerSet(chatId, [options]) ⇒ <code>Promise</code>
Use this method to delete a group sticker set from a supergroup.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletechatstickerset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletechatstickerset
| Param | Type | Description |
| --- | --- | --- |
@ -1145,8 +1223,8 @@ Use this method to delete a group sticker set from a supergroup.
### telegramBot.sendGame(chatId, gameShortName, [options]) ⇒ <code>Promise</code>
Use this method to send a game.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendgame
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendgame
| Param | Type | Description |
| --- | --- | --- |
@ -1159,8 +1237,8 @@ Use this method to send a game.
### telegramBot.setGameScore(userId, score, [options]) ⇒ <code>Promise</code>
Use this method to set the score of the specified user in a game.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setgamescore
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setgamescore
| Param | Type | Description |
| --- | --- | --- |
@ -1173,8 +1251,8 @@ Use this method to set the score of the specified user in a game.
### telegramBot.getGameHighScores(userId, [options]) ⇒ <code>Promise</code>
Use this method to get data for high score table.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getgamehighscores
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getgamehighscores
| Param | Type | Description |
| --- | --- | --- |
@ -1186,8 +1264,8 @@ Use this method to get data for high score table.
### telegramBot.deleteMessage(chatId, messageId, [options]) ⇒ <code>Promise</code>
Use this method to delete a message.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletemessage
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletemessage
| Param | Type | Description |
| --- | --- | --- |
@ -1201,8 +1279,8 @@ Use this method to delete a message.
Send invoice.
Use this method to send an invoice.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendinvoice
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#sendinvoice
| Param | Type | Description |
| --- | --- | --- |
@ -1222,8 +1300,8 @@ Use this method to send an invoice.
Answer shipping query..
Use this method to reply to shipping queries.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answershippingquery
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answershippingquery
| Param | Type | Description |
| --- | --- | --- |
@ -1237,8 +1315,8 @@ Use this method to reply to shipping queries.
Answer pre-checkout query.
Use this method to confirm shipping of a product.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answerprecheckoutquery
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#answerprecheckoutquery
| Param | Type | Description |
| --- | --- | --- |
@ -1251,8 +1329,8 @@ Use this method to confirm shipping of a product.
### telegramBot.getStickerSet(name, [options]) ⇒ <code>Promise</code>
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getstickerset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#getstickerset
| Param | Type | Description |
| --- | --- | --- |
@ -1265,8 +1343,8 @@ Use this method to get a sticker set. On success, a [StickerSet](https://core.te
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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#uploadstickerfile
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#uploadstickerfile
| Param | Type | Description |
| --- | --- | --- |
@ -1282,8 +1360,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#createnewstickerset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#createnewstickerset
**Todo**
- [ ] Add tests for this method!
@ -1305,8 +1383,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#addstickertoset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#addstickertoset
**Todo**
- [ ] Add tests for this method!
@ -1327,8 +1405,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setstickerpositioninset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#setstickerpositioninset
**Todo**
- [ ] Add tests for this method!
@ -1346,8 +1424,8 @@ 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 [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletestickerfromset
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**: https://core.telegram.org/bots/api#deletestickerfromset
**Todo**
- [ ] Add tests for this method!
@ -1368,7 +1446,7 @@ 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`.
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**See**
- https://core.telegram.org/bots/api#sendmediagroup
@ -1386,26 +1464,26 @@ add a `fileOptions` property to the target input in `media`.
### TelegramBot.errors : <code>Object</code>
The different errors the library uses.
**Kind**: static property of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: static property of [<code>TelegramBot</code>](#TelegramBot)
<a name="TelegramBot.messageTypes"></a>
### TelegramBot.messageTypes : <code>Array.&lt;String&gt;</code>
The types of message updates the library handles.
**Kind**: static property of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: static property of [<code>TelegramBot</code>](#TelegramBot)
<a name="TelegramBot.Promise"></a>
### TelegramBot.Promise
Change Promise library used internally, for all existing and new
instances.
**Kind**: static property of [<code>TelegramBot</code>](#TelegramBot)
**Kind**: static property of [<code>TelegramBot</code>](#TelegramBot)
| Param | Type |
| --- | --- |
| customPromise | <code>function</code> |
| customPromise | <code>function</code> |
**Example**
**Example**
```js
const TelegramBot = require('node-telegram-bot-api');
TelegramBot.Promise = myPromise;

View File

@ -17,7 +17,7 @@ that emits the following events:
`sticker`, `video`, `voice`, `contact`, `location`,
`new_chat_members`, `left_chat_member`, `new_chat_title`,
`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`game`, `pinned_message`, `poll`, `migrate_from_chat_id`, `migrate_to_chat_id`,
`game`, `pinned_message`, `poll`, `dice`, `migrate_from_chat_id`, `migrate_to_chat_id`,
`channel_chat_created`, `supergroup_chat_created`,
`successful_payment`, `invoice`, `video_note`
1. **Arguments**: `message` ([Message][message]), `metadata` (`{ type?:string }`)

View File

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

View File

@ -26,6 +26,7 @@ const _messageTypes = [
'channel_chat_created',
'contact',
'delete_chat_photo',
'dice',
'document',
'game',
'group_chat_created',
@ -588,6 +589,7 @@ class TelegramBot extends EventEmitter {
const shippingQuery = update.shipping_query;
const preCheckoutQuery = update.pre_checkout_query;
const poll = update.poll;
const pollAnswer = update.poll_answer;
if (message) {
debug('Process Update message %j', message);
@ -668,6 +670,9 @@ class TelegramBot extends EventEmitter {
} else if (poll) {
debug('Process Update poll %j', poll);
this.emit('poll', poll);
} else if (pollAnswer) {
debug('Process Update poll_answer %j', pollAnswer);
this.emit('poll_answer', pollAnswer);
}
}
@ -767,6 +772,28 @@ class TelegramBot extends EventEmitter {
return this._request('sendAudio', opts);
}
/**
* Send Dice
* Use this method to send a dice.
* @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#senddice
*/
sendDice(chatId, options = {}) {
const opts = {
qs: options,
};
opts.qs.chat_id = chatId;
try {
const sendData = this._formatSendData('dice');
opts.formData = sendData[0];
} catch (ex) {
return Promise.reject(ex);
}
return this._request('sendDice', opts);
}
/**
* Send Document
* @param {Number|String} chatId Unique identifier for the message recipient
@ -1016,6 +1043,42 @@ class TelegramBot extends EventEmitter {
return this._request('promoteChatMember', { form });
}
/**
* Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
* Returns True on success.
*
* @param {Number|String} chatId Unique identifier for the message recipient
* @param {Number} userId Unique identifier of the target user
* @param {String} customTitle New custom title for the administrator; 0-16 characters, emoji are not allowed
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle
*/
setChatAdministratorCustomTitle(chatId, userId, customTitle, form = {}) {
form.chat_id = chatId;
form.user_id = userId;
form.custom_title = customTitle;
return this._request('setChatAdministratorCustomTitle', { form });
}
/**
* 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.
*
* @param {Number|String} chatId Unique identifier for the message recipient
* @param {Array} chatPermissions New default chat permissions
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#setchatpermissions
*/
setChatPermissions(chatId, chatPermissions, form = {}) {
form.chat_id = chatId;
form.permissions = JSON.stringify(chatPermissions);
return this._request('setChatPermissions', { form });
}
/**
* 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.
@ -1181,6 +1244,29 @@ class TelegramBot extends EventEmitter {
return this._request('answerCallbackQuery', { form });
}
/**
* Returns True on success.
* Use this method to change the list of the bot's commands.
* @param {Array} commands Poll options, between 2-10 options
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#setmycommands
*/
setMyCommands(commands, form = {}) {
form.commands = stringify(commands);
return this._request('setMyCommands', { form });
}
/**
* Returns Array of BotCommand on success.
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#getmycommands
*/
getMyCommands(form = {}) {
return this._request('getMyCommands', { form });
}
/**
* Use this method to edit text messages sent by the bot or via
* the bot (for inline bots). On success, the edited Message is

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
test/data/photo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -43,7 +43,7 @@ const cert = `${__dirname}/../examples/ssl/crt.pem`;
const ip = '216.58.210.174'; // Google IP ¯\_(ツ)_/¯
const lat = 47.5351072;
const long = -52.7508537;
const FILE_PATH = `${__dirname}/data/photo.gif`;
const FILE_PATH = `${__dirname}/data/photo.png`;
let FILE_ID;
let GAME_CHAT_ID;
let GAME_MSG_ID;
@ -481,7 +481,7 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe.skip('#answerInlineQuery', function answerInlineQuerySuite() {});
describe.skip('#answerInlineQuery', function answerInlineQuerySuite() { });
describe('#forwardMessage', function forwardMessageSuite() {
before(function before() {
@ -507,7 +507,7 @@ describe('TelegramBot', function telegramSuite() {
utils.handleRatelimit(bot, 'sendPhoto', this);
});
it('should send a photo from file', function test() {
const photo = `${__dirname}/data/photo.gif`;
const photo = `${__dirname}/data/photo.png`;
return bot.sendPhoto(USERID, photo).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.array(resp.photo));
@ -523,21 +523,21 @@ describe('TelegramBot', function telegramSuite() {
});
});
it('should send a photo from fs.readStream', function test() {
const photo = fs.createReadStream(`${__dirname}/data/photo.gif`);
const photo = fs.createReadStream(`${__dirname}/data/photo.png`);
return bot.sendPhoto(USERID, photo).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.array(resp.photo));
});
});
it('should send a photo from request Stream', function test() {
const photo = request(`${staticUrl}/photo.gif`);
const photo = request(`${staticUrl}/photo.png`);
return bot.sendPhoto(USERID, photo).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.array(resp.photo));
});
});
it('should send a photo from a Buffer', function test() {
const photo = fs.readFileSync(`${__dirname}/data/photo.gif`);
const photo = fs.readFileSync(`${__dirname}/data/photo.png`);
return bot.sendPhoto(USERID, photo).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.array(resp.photo));
@ -817,15 +817,61 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe.skip('#kickChatMember', function kickChatMemberSuite() {});
describe.skip('#kickChatMember', function kickChatMemberSuite() { });
describe.skip('#unbanChatMember', function unbanChatMemberSuite() {});
describe.skip('#unbanChatMember', function unbanChatMemberSuite() { });
describe.skip('#restrictChatMember', function restrictChatMemberSuite() {});
describe.skip('#restrictChatMember', function restrictChatMemberSuite() { });
describe.skip('#promoteChatMember', function promoteChatMemberSuite() {});
describe.skip('#promoteChatMember', function promoteChatMemberSuite() { });
describe.skip('#answerCallbackQuery', function answerCallbackQuerySuite() {});
describe.skip('#answerCallbackQuery', function answerCallbackQuerySuite() { });
describe('#setMyCommands', function setMyCommandsSuite() {
it('should set bot commands', function test() {
const opts = [
{ command: 'eat', description: 'Command for eat' },
{ command: 'run', description: 'Command for run' }
];
return bot.setMyCommands(opts).then(resp => {
assert.ok(is.boolean(resp));
});
});
});
describe('#getMyCommands ', function getMyCommandsSuite() {
it('should get bot commands', function test() {
return bot.getMyCommands().then(resp => {
assert.ok(is.array(resp));
});
});
});
describe.skip('#setChatAdministratorCustomTitle ', function setChatAdministratorCustomTitleSuite() {
it('should set chat permissions', function test() {
return bot.setChatAdministratorCustomTitle(GROUPID, USERID, 'Custom Name').then(resp => {
assert.ok(is.boolean(resp));
});
});
});
describe('#setChatPermissions ', function setChatPermissionsSuite() {
it('should set chat permissions', function test() {
const ChatPermissions = {
can_send_messages: true,
can_send_media_messages: true,
can_send_polls: false,
can_send_other_messages: false,
can_add_web_page_previews: true,
can_change_info: false,
can_invite_users: false,
can_pin_messages: true
};
return bot.setChatPermissions(GROUPID, ChatPermissions).then(resp => {
assert.ok(is.boolean(resp));
});
});
});
describe('#exportChatInviteLink', function exportChatInviteLinkSuite() {
before(function before() {
@ -885,7 +931,8 @@ describe('TelegramBot', function telegramSuite() {
utils.handleRatelimit(bot, 'setChatTitle', this);
});
it('should set the chat title', function test() {
return bot.setChatTitle(GROUPID, 'ntba test group').then(resp => {
const random = Math.floor(Math.random() * 1000);
return bot.setChatTitle(GROUPID, `ntba test group (random: ${random})`).then(resp => {
assert.equal(resp, true);
});
});
@ -956,7 +1003,7 @@ describe('TelegramBot', function telegramSuite() {
utils.handleRatelimit(bot, 'editMessageCaption', this);
});
it('should edit a caption sent by the bot', function test() {
const photo = `${__dirname}/data/photo.gif`;
const photo = `${__dirname}/data/photo.png`;
const options = { caption: 'test caption' };
return bot.sendPhoto(USERID, photo, options).then(resp => {
assert.equal(resp.caption, 'test caption');
@ -1128,6 +1175,43 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe('#sendPoll', function sendPollSuite() {
it('should send a Poll', function test() {
const question = '¿Are you okey?';
const answers = ['Yes', 'No'];
const opts = { is_anonymous: true };
return bot.sendPoll(GROUPID, question, answers, opts).then(resp => {
assert.ok(is.object(resp));
});
});
it('should send a Quiz', function test() {
const question = '¿Are you okey?';
const answers = ['Yes', 'No'];
const opts = {
is_anonymous: true,
type: 'quiz',
correct_option_id: 0
};
return bot.sendPoll(GROUPID, question, answers, opts).then(resp => {
assert.ok(is.object(resp));
});
});
});
describe('#sendDice', function sendDiceSuite() {
it('should send a Dice', function test() {
return bot.sendDice(GROUPID).then(resp => {
assert.ok(is.object(resp));
});
});
it('should send a Dart', function test() {
const opts = { emoji: '🎯' };
return bot.sendDice(GROUPID, opts).then(resp => {
assert.ok(is.object(resp));
});
});
});
describe('#getFile', function getFileSuite() {
this.timeout(timeout);
before(function before() {
@ -1221,7 +1305,7 @@ describe('TelegramBot', function telegramSuite() {
describe('#removeTextListener', function removeTextListenerSuite() {
const regexp = /\/onText/;
const regexp2 = /\/onText/;
const callback = function noop() {};
const callback = function noop() { };
after(function after() {
bot.removeTextListener(regexp);
bot.removeTextListener(regexp2);
@ -1240,12 +1324,12 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe.skip('#onReplyToMessage', function onReplyToMessageSuite() {});
describe.skip('#onReplyToMessage', function onReplyToMessageSuite() { });
describe('#removeReplyListener', function removeReplyListenerSuite() {
const chatId = -1234;
const messageId = 1;
const callback = function noop() {};
const callback = function noop() { };
it('returns the right reply-listener', function test() {
const id = bot.onReplyToMessage(chatId, messageId, callback);
const replyListener = bot.removeReplyListener(id);
@ -1306,7 +1390,7 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe.skip('#leaveChat', function leaveChatSuite() {});
describe.skip('#leaveChat', function leaveChatSuite() { });
describe('#sendGame', function sendGameSuite() {
before(function before() {
@ -1375,9 +1459,9 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe.skip('#answerShippingQuery', function answerShippingQuerySuite() {});
describe.skip('#answerShippingQuery', function answerShippingQuerySuite() { });
describe.skip('#answerPreCheckoutQuery', function answerPreCheckoutQuerySuite() {});
describe.skip('#answerPreCheckoutQuery', function answerPreCheckoutQuerySuite() { });
describe('#getStickerSet', function getStickerSetSuite() {
before(function before() {
@ -1416,7 +1500,7 @@ describe('TelegramBot', function telegramSuite() {
return bot.sendMediaGroup(USERID, [
{
type: 'photo',
media: `${__dirname}/data/photo.gif`,
media: `${__dirname}/data/photo.png`,
},
{
type: 'video',