Skip to content

Latest commit

 

History

History
1930 lines (1421 loc) · 104 KB

api.md

File metadata and controls

1930 lines (1421 loc) · 104 KB

API Reference

Note: If you are looking for available events or usage of api, please refer usage.md.

TelegramBot

TelegramBot

Kind: global class
See: https://core.telegram.org/bots/api

new TelegramBot(token, [options])

Both request method to obtain messages are implemented. To use standard polling, set polling: true on options. Notice that webHook will need a SSL certificate. Emits message when a message arrives.

Param Type Default Description
token String Bot Token
[options] Object
[options.polling] Boolean | Object false Set true to enable polling or set options. If a WebHook has been set, it will be deleted automatically.
[options.polling.timeout] String | Number 10 Deprecated. Use options.polling.params instead. Timeout in seconds for long polling.
[options.testEnvironment] Boolean false Set true to work with test enviroment. When working with the test environment, you may use HTTP links without TLS to test your Web App.
[options.polling.interval] String | Number 300 Interval between requests in miliseconds
[options.polling.autoStart] Boolean true Start polling immediately
[options.polling.params] Object Parameters to be used in polling API requests. See https://core.telegram.org/bots/api#getupdates for more information.
[options.polling.params.timeout] Number 10 Timeout in seconds for long polling.
[options.webHook] Boolean | Object false Set true to enable WebHook or set options
[options.webHook.host] String "0.0.0.0" Host to bind to
[options.webHook.port] Number 8443 Port to bind to
[options.webHook.key] String Path to file with PEM private key for webHook server. The file is read synchronously!
[options.webHook.cert] String Path to file with PEM certificate (public) for webHook server. The file is read synchronously!
[options.webHook.pfx] String Path to file with PFX private key and certificate chain for webHook server. The file is read synchronously!
[options.webHook.autoOpen] Boolean true Open webHook immediately
[options.webHook.https] Object Options to be passed to https.createServer(). Note that options.webHook.key, options.webHook.cert and options.webHook.pfx, if provided, will be used to override key, cert and pfx in this object, respectively. See https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener for more information.
[options.webHook.healthEndpoint] String "/healthz" An endpoint for health checks that always responds with 200 OK
[options.onlyFirstMatch] Boolean false Set to true to stop after first match. Otherwise, all regexps are executed
[options.request] Object Options which will be added for all requests to telegram api. See https://github.com/request/request#requestoptions-callback for more information.
[options.baseApiUrl] String "https://api.telegram.org" API Base URl; useful for proxying and testing
[options.filepath] Boolean true Allow passing file-paths as arguments when sending files, such as photos using TelegramBot#sendPhoto(). See usage information for more information on this option and its consequences.
[options.badRejection] Boolean false Set to true if and only if the Node.js version you're using terminates the process on unhandled rejections. This option is only for forward-compatibility purposes.

telegramBot.on(event, listener)

Add listener for the specified event. This is the usual emitter.on() method.

Kind: instance method of TelegramBot
See

Param Type
event String
listener function

telegramBot.startPolling([options]) ⇒ Promise

Start polling. Rejects returned promise if a WebHook is being used by this instance.

Kind: instance method of TelegramBot

Param Type Default Description
[options] Object
[options.restart] Boolean true Consecutive calls to this method causes polling to be restarted

telegramBot.initPolling([options]) ⇒ Promise

Deprecated

Alias of TelegramBot#startPolling(). This is deprecated.

Kind: instance method of TelegramBot

Param Type
[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.

Kind: instance method of TelegramBot

Param Type Description
[options] Object Options
[options.cancel] Boolean Cancel current request
[options.reason] String Reason for stopping polling

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.

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
Returns: Promise - Promise which will have fileURI in resolve callback
See: https://core.telegram.org/bots/api#getfile

Param Type Description
fileId String File identifier to get info about
[options] Object Additional Telegram query options

telegramBot.getFileStream(fileId, [options]) ⇒ stream.Readable

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 method, which returns the full URI to the file on remote server.

Kind: instance method of TelegramBot
Returns: stream.Readable - fileStream

Param Type Description
fileId String File identifier to get info about
[options] Object Additional Telegram query options

telegramBot.downloadFile(fileId, downloadDir, [options]) ⇒ Promise

Downloads file in the specified folder.

This method is a sugar extension of the getFileStream method, which returns a readable file stream.

Kind: instance method of TelegramBot
Returns: Promise - Promise, which will have filePath of downloaded file in resolve callback

Param Type Description
fileId String File identifier to get info about
downloadDir String Absolute path to the folder in which file will be saved
[options] Object Additional Telegram query options

telegramBot.onText(regexpRexecuted, callback)

Register a RegExp to test against an incomming text message.

Kind: instance method of TelegramBot

Param Type Description
regexpRexecuted RegExp with exec.
callback function Callback will be called with 2 parameters, the msg and the result of executing regexp.exec on message text.

telegramBot.removeTextListener(regexp) ⇒ Object

Remove a listener registered with onText().

Kind: instance method of 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.onReplyToMessage(chatId, messageId, callback) ⇒ Number

Register a reply to wait for a message response.

Kind: instance method of TelegramBot
Returns: Number - id The ID of the inserted reply listener.

Param Type Description
chatId Number | String The chat id where the message cames from.
messageId Number | String The message id to be replied.
callback function Callback will be called with the reply message.

telegramBot.removeReplyListener(replyListenerId) ⇒ Object

Removes a reply that has been prev. registered for a message response.

Kind: instance method of 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.clearReplyListeners() ⇒ Array

Removes all replies that have been prev. registered for a message response.

Kind: instance method of TelegramBot
Returns: Array - deletedListeners An array of removed listeners.

telegramBot.isPolling() ⇒ Boolean

Return true if polling. Otherwise, false.

Kind: instance method of 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.

Kind: instance method of TelegramBot

telegramBot.closeWebHook() ⇒ Promise

Close webhook after closing all current connections. Multiple invocations do nothing if webhook is already closed.

Kind: instance method of TelegramBot
Returns: Promise - Promise

telegramBot.hasOpenWebHook() ⇒ Boolean

Return true if using webhook and it is open i.e. accepts connections. Otherwise, false.

Kind: instance method of TelegramBot

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.

Kind: instance method of TelegramBot
See: https://core.telegram.org/bots/api#update

Param Type
update Object

telegramBot.getUpdates([options]) ⇒ Promise

Use this method to receive incoming updates using long polling. This method has an older, compatible signature that is being deprecated.

Kind: instance method of TelegramBot
See: https://core.telegram.org/bots/api#getupdates

Param Type Description
[options] Object Additional Telegram query options

telegramBot.setWebHook(url, [options], [fileOptions]) ⇒ Promise

Specify an url to receive incoming updates via an outgoing webHook. This method has an older, compatible signature that is being deprecated.

Kind: instance method of TelegramBot
See

Param Type Description
url String URL where Telegram will make HTTP Post. Leave empty to delete webHook.
[options] Object Additional Telegram query options
[options.certificate] String | stream.Stream PEM certificate key (public).
[fileOptions] Object Optional file related meta-data

telegramBot.deleteWebHook([options]) ⇒ Promise

Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.

Kind: instance method of TelegramBot
See: https://core.telegram.org/bots/api#deletewebhook

Param Type Description
[options] Object Additional Telegram query options

telegramBot.getWebHookInfo([options]) ⇒ Promise

Use this method to get current webhook status. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.

Kind: instance method of TelegramBot
See: https://core.telegram.org/bots/api#getwebhookinfo

Param Type Description
[options] Object Additional Telegram query options

telegramBot.getMe([options]) ⇒ Promise

A simple method for testing your bot's authentication token. Requires no parameters.

Kind: instance method of TelegramBot
Returns: Promise - basic information about the bot in form of a User object.
See: https://core.telegram.org/bots/api#getme

Param Type Description
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#logout

Param Type Description
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#close

Param Type Description
[options] Object Additional Telegram query options

telegramBot.sendMessage(chatId, text, [options]) ⇒ Promise

Send text message.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See: https://core.telegram.org/bots/api#sendmessage

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
text String Text of the message to be sent
[options] Object Additional Telegram query options

telegramBot.forwardMessage(chatId, fromChatId, messageId, [options]) ⇒ Promise

Forward messages of any kind.

Kind: instance method of TelegramBot
See: https://core.telegram.org/bots/api#forwardmessage

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername) or username of the target channel (in the format @channelusername)
fromChatId Number | String Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
messageId Number | String Unique message identifier in the chat specified in fromChatId
[options] Object Additional Telegram query options

telegramBot.copyMessage(chatId, fromChatId, messageId, [options]) ⇒ Promise

Copy messages of any kind. Service messages and invoice messages can't be copied. 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
Returns: Promise - The MessageId of the sent message on success
See: https://core.telegram.org/bots/api#copymessage

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
fromChatId Number | String Unique identifier for the chat where the original message was sent
messageId Number | String Unique message identifier
[options] Object Additional Telegram query options

telegramBot.sendPhoto(chatId, photo, [options], [fileOptions]) ⇒ Promise

Send photo

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
photo String | stream.Stream | Buffer A file path or a Stream. Can also be a file_id previously uploaded
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.sendAudio(chatId, audio, [options], [fileOptions]) ⇒ Promise

Send audio

Your audio must be in the .MP3 or .M4A format.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
audio String | stream.Stream | Buffer A file path, Stream or Buffer. Can also be a file_id previously uploaded.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.sendDocument(chatId, doc, [options], [fileOptions]) ⇒ Promise

Send Document

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
doc String | stream.Stream | Buffer A file path, Stream or Buffer. Can also be a file_id previously uploaded.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

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
Returns: Promise - On success, the sent Message object is returned
See

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
video String | stream.Stream | Buffer A file path or Stream. Can also be a file_id previously uploaded.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

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
Returns: Promise - On success, the sent Message object is returned
See

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
animation String | stream.Stream | Buffer A file path, Stream or Buffer. Can also be a file_id previously uploaded.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.sendVoice(chatId, voice, [options], [fileOptions]) ⇒ Promise

Send voice

Your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document)

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
voice String | stream.Stream | Buffer A file path, Stream or Buffer. Can also be a file_id previously uploaded.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.sendVideoNote(chatId, videoNote, [options], [fileOptions]) ⇒ Promise

Use this method to send video messages Telegram clients support rounded square MPEG4 videos of up to 1 minute long.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
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

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
videoNote String | stream.Stream | Buffer A file path or Stream. Can also be a file_id previously uploaded.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.sendMediaGroup(chatId, media, [options]) ⇒ Promise

Use this method to send a group of photos or videos as an album.

Documents and audio files can be only grouped in an album with messages of the same type

If you wish to specify file options, add a fileOptions property to the target input in media.

Kind: instance method of TelegramBot
Returns: Promise - On success, an array of the sent Messages is returned.
See

Param Type Description
chatId String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
media Array A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
[options] Object Additional Telegram query options

telegramBot.sendLocation(chatId, latitude, longitude, [options]) ⇒ Promise

Send location. Use this method to send point on the map.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See: https://core.telegram.org/bots/api#sendlocation

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
latitude Float Latitude of location
longitude Float Longitude of location
[options] Object Additional Telegram query options

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).

A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation

Note that you must provide one of chat_id, message_id, or inline_message_id in your request.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
See: https://core.telegram.org/bots/api#editmessagelivelocation

Param Type Description
latitude Float Latitude of location
longitude Float Longitude of location
[options] Object Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)

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.

Note that you must provide one of chat_id, message_id, or inline_message_id in your request.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
See: https://core.telegram.org/bots/api#stopmessagelivelocation

Param Type Description
[options] Object Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)

telegramBot.sendVenue(chatId, latitude, longitude, title, address, [options]) ⇒ Promise

Send venue. Use this method to send information about a venue.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned.
See: https://core.telegram.org/bots/api#sendvenue

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
latitude Float Latitude of location
longitude Float Longitude of location
title String Name of the venue
address String Address of the venue
[options] Object Additional Telegram query options

telegramBot.sendContact(chatId, phoneNumber, firstName, [options]) ⇒ Promise

Send contact. Use this method to send phone contacts.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See: https://core.telegram.org/bots/api#sendcontact

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
phoneNumber String Contact's phone number
firstName String Contact's first name
[options] Object Additional Telegram query options

telegramBot.sendPoll(chatId, question, pollOptions, [options]) ⇒ Promise

Send poll. Use this method to send a native poll.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See: https://core.telegram.org/bots/api#sendpoll

Param Type Description
chatId Number | String Unique identifier for the group/channel
question String Poll question, 1-300 characters
pollOptions Array Poll options, between 2-10 options (only 1-100 characters each)
[options] Object Additional Telegram query options

telegramBot.sendDice(chatId, [options]) ⇒ Promise

Send Dice Use this method to send an animated emoji that will display a random value.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message object is returned
See: https://core.telegram.org/bots/api#senddice

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
[options] Object Additional Telegram query options

telegramBot.sendChatAction(chatId, action, [options]) ⇒ Promise

Send chat action.

Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).

Action typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#sendchataction

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
action String Type of action to broadcast.
[options] Object Additional Telegram query options

telegramBot.getUserProfilePhotos(userId, [options]) ⇒ Promise

Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. This method has an older, compatible signature that is being deprecated.

Kind: instance method of TelegramBot
Returns: Promise - Returns a UserProfilePhotos object
See: https://core.telegram.org/bots/api#getuserprofilephotos

Param Type Description
userId Number Unique identifier of the target user
[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.

Kind: instance method of TelegramBot
Returns: Promise - On success, a File object is returned
See: https://core.telegram.org/bots/api#getfile

Param Type Description
fileId String File identifier to get info about
[options] Object Additional Telegram query options

telegramBot.banChatMember(chatId, userId, [options]) ⇒ Promise

Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first..

The bot must be an administrator in the group, supergroup or a channel for this to work.

Kind: instance method of TelegramBot
Returns: Promise - True on success.
See: https://core.telegram.org/bots/api#banchatmember

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

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 supergroup or channel for this to work.

By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#unbanchatmember

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#restrictchatmember

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success.
See: https://core.telegram.org/bots/api#promotechatmember

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
userId Number
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchatadministratorcustomtitle

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
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.banChatSenderChat(chatId, senderChatId, [options]) ⇒ Promise

Use this method to ban a channel chat in a supergroup or a channel.

Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights

Kind: instance method of TelegramBot
Returns: Promise - True on success.
See: https://core.telegram.org/bots/api#banchatsenderchat

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
senderChatId Number Unique identifier of the target user
[options] Object Additional Telegram query options

telegramBot.unbanChatSenderChat(chatId, senderChatId, [options]) ⇒ Promise

Use this method to unban a previously banned channel chat in a supergroup or channel.

The bot must be an administrator for this to work and must have the appropriate administrator rights.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#unbanchatsenderchat

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
senderChatId Number Unique identifier of the target user
[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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchatpermissions

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
chatPermissions Array New default chat permissions
[options] Object Additional Telegram query options

telegramBot.exportChatInviteLink(chatId, [options]) ⇒ Promise

Use this method to generate a new primary invite link for a chat. Any previously generated primary link is revoked.

The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Kind: instance method of TelegramBot
Returns: Promise - Exported invite link as String on success.
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 channel (in the format @channelusername)
[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.

The link generated with this method can be revoked using the method revokeChatInviteLink

Kind: instance method of TelegramBot
Returns: Object - The new invite link as ChatInviteLink object
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 channel (in the format @channelusername)
[options] Object Additional Telegram query options

telegramBot.editChatInviteLink(chatId, inviteLink, [options]) ⇒ Promise

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.

Kind: instance method of TelegramBot
Returns: Promise - The edited invite link as a ChatInviteLink object
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 channel (in the format @channelusername)
inviteLink String Text with the invite link to edit
[options] Object Additional Telegram query options

telegramBot.revokeChatInviteLink(chatId, [options]) ⇒ Promise

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.

Kind: instance method of TelegramBot
Returns: Promise - The revoked invite link as ChatInviteLink object
See: https://core.telegram.org/bots/api#revokechatinvitelink

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
[options] Object Additional Telegram query options

telegramBot.approveChatJoinRequest(chatId, userId, [options]) ⇒ Promise

Use this method to approve a chat join request.

The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#approvechatjoinrequest

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

telegramBot.declineChatJoinRequest(chatId, userId, [options]) ⇒ Promise

Use this method to decline a chat join request.

The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#declinechatjoinrequest

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchatphoto

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
photo stream.Stream | Buffer A file path or a Stream.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#deletechatphoto

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
[options] Object Additional Telegram query options

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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchattitle

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
title String New chat title, 1-255 characters
[options] Object Additional Telegram query options

telegramBot.setChatDescription(chatId, description, [options]) ⇒ Promise

Use this method to change the description of a group, 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.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchatdescription

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
description String New chat title, 0-255 characters
[options] Object Additional Telegram query options

telegramBot.pinChatMessage(chatId, messageId, [options]) ⇒ Promise

Use this method to pin a message in a supergroup.

If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in a supergroup or can_edit_messages administrator right in a channel.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#pinchatmessage

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
messageId Number Identifier of a message to pin
[options] Object Additional Telegram query options

telegramBot.unpinChatMessage(chatId, [options]) ⇒ Promise

Use this method to remove a message from the list of pinned messages in a chat

If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in a supergroup or can_edit_messages administrator right in a channel.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#unpinchatmessage

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
[options] Object Additional Telegram query options

telegramBot.unpinAllChatMessages(chatId, [options]) ⇒ Promise

Use this method to clear the list of pinned messages in a chat.

If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in a supergroup or can_edit_messages administrator right in a channel.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#unpinallchatmessages

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
[options] Object Additional Telegram query options

telegramBot.leaveChat(chatId, [options]) ⇒ Promise

Use this method for your bot to leave a group, supergroup or channel

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#leavechat

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
[options] Object Additional Telegram query options

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.).

Kind: instance method of TelegramBot
Returns: Promise - Chat object on success
See: https://core.telegram.org/bots/api#getchat

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername) or channel
[options] Object Additional Telegram query options

telegramBot.getChatAdministrators(chatId, [options]) ⇒ Promise

Use this method to get a list of administrators in a chat

Kind: instance method of TelegramBot
Returns: Promise - On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned
See: https://core.telegram.org/bots/api#getchatadministrators

Param Type Description
chatId Number | String Unique identifier for the target group or username of the target supergroup
[options] Object Additional Telegram query options

telegramBot.getChatMemberCount(chatId, [options]) ⇒ Promise

Use this method to get the number of members in a chat.

Kind: instance method of TelegramBot
Returns: Promise - Int on success
See: https://core.telegram.org/bots/api#getchatmembercount

Param Type Description
chatId Number | String Unique identifier for the target group or username of the target supergroup
[options] Object Additional Telegram query options

telegramBot.getChatMember(chatId, userId, [options]) ⇒ Promise

Use this method to get information about a member of a chat.

Kind: instance method of TelegramBot
Returns: Promise - ChatMember object on success
See: https://core.telegram.org/bots/api#getchatmember

Param Type Description
chatId Number | String Unique identifier for the target group or username of the target supergroup
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

telegramBot.setChatStickerSet(chatId, stickerSetName, [options]) ⇒ Promise

Use this method to set a new group sticker set for a supergroup.

The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Note: Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchatstickerset

Param Type Description
chatId Number | String Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
stickerSetName String Name of the sticker set to be set as the group sticker set
[options] Object Additional Telegram query options

telegramBot.deleteChatStickerSet(chatId, [options]) ⇒ Promise

Use this method to delete a group sticker set from a supergroup.

Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#deletechatstickerset

Param Type Description
chatId Number | String Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
[options] Object Additional Telegram query options

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.

This method has older, compatible signatures (1)(2) that are being deprecated.

Kind: instance method of TelegramBot
Returns: Promise - True on success
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.setMyCommands(commands, [options]) ⇒ Promise

Use this method to change the list of the bot's commands.

See https://core.telegram.org/bots#commands for more details about bot commands

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setmycommands

Param Type Description
commands Array 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.deleteMyCommands([options]) ⇒ Promise

Use this method to delete the list of the bot's commands for the given scope and user language.

After deletion, higher level commands will be shown to affected users.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#deletemycommands

Param Type Description
[options] Object Additional Telegram query options

telegramBot.getMyCommands([options]) ⇒ Promise

Use this method to get the current list of the bot's commands for the given scope and user language.

Kind: instance method of TelegramBot
Returns: Promise - Array of BotCommand on success. If commands aren't set, an empty list is returned.
See: https://core.telegram.org/bots/api#getmycommands

Param Type Description
[options] Object Additional Telegram query options

telegramBot.setChatMenuButton([options]) ⇒ Promise

Use this method to change the bot's menu button in a private chat, or the default menu button.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setchatmenubutton

Param Type Description
[options] Object Additional Telegram query options

telegramBot.getChatMenuButton([options]) ⇒ Promise

Use this method to get the current value of the bot's menu button in a private chat, or the default menu button.

Kind: instance method of TelegramBot
Returns: Promise - MenuButton on success
See: https://core.telegram.org/bots/api#getchatmenubutton

Param Type Description
[options] Object Additional Telegram query options

telegramBot.setMyDefaultAdministratorRights([options]) ⇒ Promise

Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels.

These rights will be suggested to users, but they are are free to modify the list before adding the bot.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#getchatmenubutton

Param Type Description
[options] Object Additional Telegram query options

telegramBot.getMyDefaultAdministratorRights([options]) ⇒ Promise

Use this method to get the current default administrator rights of the bot.

Kind: instance method of TelegramBot
Returns: Promise - ChatAdministratorRights on success
See: https://core.telegram.org/bots/api#getmydefaultadministratorrights

Param Type Description
[options] Object Additional Telegram query options

telegramBot.editMessageText(text, [options]) ⇒ Promise

Use this method to edit text or game 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.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned
See: https://core.telegram.org/bots/api#editmessagetext

Param Type Description
text String New text of the message
[options] Object Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)

telegramBot.editMessageCaption(caption, [options]) ⇒ Promise

Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).

Note: You must provide one of chat_id, message_id, or inline_message_id in your request.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned
See: https://core.telegram.org/bots/api#editmessagecaption

Param Type Description
caption String New caption of the message
[options] Object Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)

telegramBot.editMessageMedia(media, [options]) ⇒ Promise

Use this method to edit animation, 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.

Note: You must provide one of chat_id, message_id, or inline_message_id in your request.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned
See: https://core.telegram.org/bots/api#editmessagemedia

Param Type Description
media Object A JSON-serialized object for a new media content of the message
[options] Object Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)

telegramBot.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).

Note: You must provide one of chat_id, message_id, or inline_message_id in your request.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned
See: https://core.telegram.org/bots/api#editmessagetext

Param Type Description
replyMarkup Object A JSON-serialized object for an inline keyboard.
[options] Object Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)

telegramBot.stopPoll(chatId, pollId, [options]) ⇒ Promise

Use this method to stop a poll which was sent by the bot.

Kind: instance method of TelegramBot
Returns: Promise - On success, the stopped Poll is returned
See: https://core.telegram.org/bots/api#stoppoll

Param Type Description
chatId Number | String Unique identifier for the group/channel
pollId Number Identifier of the original message with the poll
[options] Object Additional Telegram query options

telegramBot.deleteMessage(chatId, messageId, [options]) ⇒ Promise

Use this method to delete a message, including service messages, with the following limitations:

  • A message can only be deleted if it was sent less than 48 hours ago.
  • A dice message can only be deleted if it was sent more than 24 hours ago.
  • Bots can delete outgoing messages in groups and supergroups.
  • Bots can delete incoming messages in groups, supergroups and channels.
  • Bots granted can_post_messages permissions can delete outgoing messages in channels.
  • If the bot is an administrator of a group, it can delete any message there.
  • If the bot has can_delete_messages permission in a supergroup, it can delete any message there.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#deletemessage

Param Type Description
chatId Number | String Unique identifier of the target chat
messageId Number Unique identifier of the target message
[options] Object Additional Telegram query options

telegramBot.sendSticker(chatId, sticker, [options], [fileOptions]) ⇒ Promise

Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message is returned
See: https://core.telegram.org/bots/api#sendsticker

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
sticker String | stream.Stream | Buffer A file path, Stream or Buffer. Can also be a file_id previously uploaded. Stickers are WebP format files.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.getStickerSet(name, [options]) ⇒ Promise

Use this method to get a sticker set.

Kind: instance method of TelegramBot
Returns: Promise - On success, a StickerSet object is returned
See: https://core.telegram.org/bots/api#getstickerset

Param Type Description
name String Name of the sticker set
[options] Object Additional Telegram query options

telegramBot.getCustomEmojiStickers(custom_emoji_ids, [options]) ⇒ Promise

Use this method to get information about custom emoji stickers by their identifiers.

Kind: instance method of TelegramBot
Returns: Promise - Array of Sticker objects.
See: https://core.telegram.org/bots/api#getcustomemojistickers

Param Type Description
custom_emoji_ids Array List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
[options] Object Additional Telegram query options

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).

Kind: instance method of TelegramBot
Returns: Promise - On success, a File object is returned
See: https://core.telegram.org/bots/api#uploadstickerfile

Param Type Description
userId Number User identifier of sticker file owner
pngSticker String | stream.Stream | Buffer A file path or a Stream. Can also be a file_id previously uploaded. Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

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.

You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#createnewstickerset

Param Type Description
userId Number User identifier of created sticker set owner
name String Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., "animals"). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in . is case insensitive. 1-64 characters.
title String Sticker set title, 1-64 characters
pngSticker String | stream.Stream | Buffer Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
emojis String One or more emoji corresponding to the sticker
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.addStickerToSet(userId, name, sticker, emojis, stickerType, [options], [fileOptions]) ⇒ Promise

Use this method to add a new sticker to a set created by the bot.

You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker

Animated stickers can be added to animated sticker sets and only to them:

  • Animated sticker sets can have up to 50 stickers.
  • Static sticker sets can have up to 120 stickers

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#addstickertoset

Param Type Default Description
userId Number User identifier of sticker set owner
name String Sticker set name
sticker String | stream.Stream | Buffer Png image with the sticker (must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px, TGS animation with the sticker or WEBM video with the sticker.
emojis String One or more emoji corresponding to the sticker
stickerType String png_sticker Allow values: png_sticker, tgs_sticker, or webm_sticker.
[options] Object Additional Telegram query options
[fileOptions] Object Optional file related meta-data

telegramBot.setStickerPositionInSet(sticker, position, [options]) ⇒ Promise

Use this method to move a sticker in a set created by the bot to a specific position.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setstickerpositioninset

Param Type Description
sticker String File identifier of the sticker
position Number New sticker position in the set, zero-based
[options] Object Additional Telegram query options

telegramBot.deleteStickerFromSet(sticker, [options]) ⇒ Promise

Use this method to delete a sticker from a set created by the bot.

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#deletestickerfromset
Todo

  • Add tests for this method!
Param Type Description
sticker String File identifier of the sticker
[options] Object Additional Telegram query options

telegramBot.setStickerSetThumb(userId, name, pngThumb, [options], [fileOptions]) ⇒ Promise

Use this method to add a thumb to a set created by the bot.

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

Kind: instance method of TelegramBot
Returns: Promise - True on success
See: https://core.telegram.org/bots/api#setstickersetthumb

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

telegramBot.answerInlineQuery(inlineQueryId, results, [options]) ⇒ Promise

Send answers to an inline query.

Note: No more than 50 results per query are allowed.

Kind: instance method of TelegramBot
Returns: Promise - On success, True is returned
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
[options] Object Additional Telegram query options

telegramBot.answerWebAppQuery(webAppQueryId, result, [options]) ⇒ Promise

Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated.

Kind: instance method of TelegramBot
Returns: Promise - On success, a SentWebAppMessage object is returned
See: https://core.telegram.org/bots/api#answerwebappquery

Param Type Description
webAppQueryId String Unique identifier for the query to be answered
result InlineQueryResult object that represents one result of an inline query
[options] Object Additional Telegram query options

telegramBot.sendInvoice(chatId, title, description, payload, providerToken, currency, prices, [options]) ⇒ Promise

Use this method to send an invoice.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message is returned
See: https://core.telegram.org/bots/api#sendinvoice

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
title String Product name, 1-32 characters
description String Product description, 1-255 characters
payload String Bot defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
providerToken String Payments provider token, obtained via @BotFather
currency String Three-letter ISO 4217 currency code
prices Array Breakdown of prices
[options] Object Additional Telegram query options

telegramBot.createInvoiceLink(title, description, payload, providerToken, currency, prices, [options]) ⇒ Promise

Use this method to create a link for an invoice.

Kind: instance method of TelegramBot
Returns: Promise - The created invoice link as String on success.
See: https://core.telegram.org/bots/api#createinvoicelink

Param Type Description
title String Product name, 1-32 characters
description String Product description, 1-255 characters
payload String Bot defined invoice payload
providerToken String Payment provider token
currency String Three-letter ISO 4217 currency code
prices Array Breakdown of prices
[options] Object Additional Telegram query options

telegramBot.answerShippingQuery(shippingQueryId, ok, [options]) ⇒ Promise

Use this method to reply to shipping queries.

If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot

Kind: instance method of TelegramBot
Returns: Promise - On success, True is returned
See: https://core.telegram.org/bots/api#answershippingquery

Param Type Description
shippingQueryId String Unique identifier for the query to be answered
ok Boolean Specify if delivery of the product is possible
[options] Object Additional Telegram query options

telegramBot.answerPreCheckoutQuery(preCheckoutQueryId, ok, [options]) ⇒ Promise

Use this method to respond to such pre-checkout queries

Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query.

Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

Kind: instance method of TelegramBot
Returns: Promise - On success, True is returned
See: https://core.telegram.org/bots/api#answerprecheckoutquery

Param Type Description
preCheckoutQueryId String Unique identifier for the query to be answered
ok Boolean Specify if every order details are ok
[options] Object Additional Telegram query options

telegramBot.sendGame(chatId, gameShortName, [options]) ⇒ Promise

Use this method to send a game.

Kind: instance method of TelegramBot
Returns: Promise - On success, the sent Message is returned
See: https://core.telegram.org/bots/api#sendgame

Param Type Description
chatId Number | String Unique identifier for the target chat or username of the target channel (in the format @channelusername)
gameShortName String name of the game to be sent. Set up your games via @BotFather.
[options] Object Additional Telegram query options

telegramBot.setGameScore(userId, score, [options]) ⇒ Promise

Use this method to set the score of the specified user in a game message.

Kind: instance method of TelegramBot
Returns: Promise - On success, if the message is not an inline message, the Message is returned, otherwise True is returned
See: https://core.telegram.org/bots/api#setgamescore

Param Type Description
userId Number Unique identifier of the target user
score Number New score value, must be non-negative
[options] Object Additional Telegram query options

telegramBot.getGameHighScores(userId, [options]) ⇒ Promise

Use this method to get data for high score tables.

Will return the score of the specified user and several of their neighbors in a game.

Kind: instance method of TelegramBot
Returns: Promise - On success, returns an Array of GameHighScore objects
See: https://core.telegram.org/bots/api#getgamehighscores

Param Type Description
userId Number Unique identifier of the target user
[options] Object Additional Telegram query options

TelegramBot.errors : Object

The different errors the library uses.

Kind: static property of TelegramBot

TelegramBot.messageTypes : [ 'Array' ].<String>

The types of message updates the library handles.

Kind: static property of TelegramBot