-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference Version 1.1.0
Object to wrap file uploads to Telegram via multipart/form-data
.
The input can be a Stream
for binary reading or a Path
to the file.
Param | Type | Description |
---|---|---|
name | string |
the name of the file |
source |
io.Stream | fs.Path
|
input binary stream or a path to the file |
Kind: global class
-
TelegramBot
- new TelegramBot(token)
- .setWebhook(url, cert)
- .getUpdates(options)
- .getMe()
- .sendMessage(chatId, text, options)
- .answerInlineQuery(inlineQueryId, results, options)
- .forwardMessage(chatId, fromChatId, messageId, options)
- .sendPhoto(chatId, photo, options)
- .sendAudio(chatId, audio, options)
- .sendDocument(chatId, document, options)
- .sendSticker(chatId, sticker, options)
- .sendVideo(chatId, video, options)
- .sendVideoNote(chatId, videoNote, options)
- .sendVoice(chatId, voice, options)
- .sendLocation(chatId, latitude, longitude, options)
- .sendVenue(chatId, latitude, longitude, title, address, options)
- .sendContact(chatId, phoneNumber, firstName, options)
- .sendChatAction(chatId, action)
- .getUserProfilePhotos(userId, options)
- .getFile(fileId)
- .kickChatMember(chatId, userId)
- .leaveChat(chatId)
- .unbanChatMember(chatId, userId)
- .getChat(chatId)
- .getChatAdministrators(chatId)
- .getChatMembersCount(chatId)
- .getChatMember(chatId, userId)
- .answerCallbackQuery(callbackQueryId, options)
- .editMessageText(text, options)
- .editMessageCaption(options)
- .editMessageReplyMarkup(options)
- .getWebhookInfo()
- .deleteMessage(chatId, messageId)
- .restrictChatMember(chatId, userId, options)
- .promoteChatMember(chatId, userId, options)
- .exportChatInviteLink(chatId)
- .setChatPhoto(chatId, photo)
- .deleteChatPhoto(chatId)
- .setChatTitle(chatId, title)
- .setChatDescription(chatId, description)
- .pinChatMessage(chatId, messageId, options)
- .unpinChatMessage(chatId)
- .getStickerSet(name)
- .uploadStickerFile(userId, pngSticker)
- .createNewStickerSet(userId, name, title, pngSticker, emojis, options)
- .addStickerToSet(userId, name, title, pngSticker, emojis, options)
- .setStickerPositionInSet(sticker, position)
- .deleteStickerFromSet(sticker)
A Telegram Bot API client. It manages the HTTPS-based communication with the API endpoint.
Param | Type | Description |
---|---|---|
token | string |
the bot's unique authentication token |
Registers a webhook for the bot. The provided URL must be using HTTPS for secure communication.
Kind: instance method of TelegramBot
See: Telegram Bot API - setWebhook
Param | Type | Description |
---|---|---|
url | string |
the bot's HTTPS callback URL. An empty string removes the webhook. |
cert | MultipartStream |
optional self-signed public key certificate |
Retrieves updates using long polling requests.
Kind: instance method of TelegramBot
See: Telegram Bot API - getUpdates
Param | Type | Description |
---|---|---|
options | Object |
optional parameters |
Test method to verify the auth token is working. Returns basic information about the bot.
Kind: instance method of TelegramBot
See: Telegram Bot API - getMe
Sends a text message. On success, the sent message is returned.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendMessage
Param | Type | Description |
---|---|---|
chatId |
number | string
|
identifier for the target chat |
text | string |
message text |
options | Object |
optional parameters |
Answers inline queries for inline-enabled bots. No more than 50 results per query are allowed.
Kind: instance method of TelegramBot
See: Telegram Bot API - answerInlineQuery
Param | Type | Description |
---|---|---|
inlineQueryId |
numer | string
|
the query id |
results | Array |
array of InlineQueryResult objects |
options | Object |
optional parameters |
Example
updates.forEach(function(update) {
if (utils.isInlineQuery(update)) {
let query = utils.getInlineQuery(update);
let searchResults = [
{
"type": "article",
"id": "http://orf.at/stories/2353452/2353453/",
"url": "http://orf.at/stories/2353452/2353453/",
"title": "Noch mehr grünes Wasser",
"description": "Jetzt sind beide Becken grün.",
"thumb_url": "http://orf.at/static/4705004.jpg",
"thumb_width": 640,
"thumb_height": 360,
"input_message_content": {
"message_text": "Oje, noch mehr grünes Wasser!"
}
}
];
bot.answerInlineQuery(query.id, searchResults, {
cache_time: 5
});
}
});
Forwards messages of any kind to another chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - forwardMessage
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
fromChatId |
number | string
|
source chat id |
messageId |
number | string
|
message id from the source chat |
options | Object |
optional parameters |
Sends a photo to a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendPhoto
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
photo | MultipartStream |
multipart photo object |
options | Object |
optional parameters |
Sends an audio message to a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendAudio
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
audio | MultipartStream |
multipart audio object |
options | Object |
optional parameters |
Sends a document to a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendDocument
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
document | MultipartStream |
multipart document object |
options | Object |
optional parameters |
Sends a .webp
sticker to a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendSticker
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
sticker | MultipartStream |
multipart sticker object |
options | Object |
optional parameters |
Sends a mp4
video to the chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendVideo
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
video | MultipartStream |
multipart video object |
options | Object |
optional parameters |
Sends a mp4
video note of up to 1 minute long to the chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendVideoNote
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
videoNote | MultipartStream |
multipart video object |
options | Object |
optional parameters |
Sends a voice message encoded with ogg and the low-latency Opus lossy audio coding format.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendVoice
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
voice | MultipartStream |
multipart voice recording object |
options | Object |
optional parameters |
Sends a point on a map.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendLocation
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
latitude | number |
numeric latitude |
longitude | number |
numeric longitude |
options | Object |
optional parameters |
Sends detailed information about a venue.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendVenue
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
latitude | number |
numeric latitude |
longitude | number |
numeric longitude |
title | string |
venue name or title |
address | string |
detailed address of the venue |
options | Object |
optional parameters |
Sends a contact. The optional last_name
has to be sent in the additional parameters.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendContact
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
phoneNumber | string |
phone number as string |
firstName | string |
contact's first name |
options | Object |
optional parameters |
Sends a work in progress indicator to the user. This might be useful if the bot needs more time to answer a specific message by the user.
Kind: instance method of TelegramBot
See: Telegram Bot API - sendChatAction
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
action | string |
type of action or response a user will see in the future |
Retrieves a list of profile pictures for a user.
Kind: instance method of TelegramBot
See: Telegram Bot API - getUserProfilePhotos
Param | Type | Description |
---|---|---|
userId |
number | string
|
user identifier |
options | Object |
optional parameters |
Retrieves basic information about the requested file and prepares it for downloading.
Kind: instance method of TelegramBot
See: Telegram Bot API - getFile
Param | Type |
---|---|
fileId | string |
Kicks a user from a group or a supergroup.
Kind: instance method of TelegramBot
See: Telegram Bot API - kickChatMember
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
userId |
number | string
|
user to kick |
Lets a bot leave a group, supergroup or channel. The method returns true
on success.
Kind: instance method of TelegramBot
See: Telegram Bot API - leaveChat
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
Annuls a ban of a chat member for the given supergroup. The user must join again via a link or invite.
Kind: instance method of TelegramBot
See: Telegram Bot API - unbanChatMember
Param | Type | Description |
---|---|---|
chatId |
number | string
|
the target chat id |
userId |
number | string
|
user to unban |
Retrieves detailed information about the given chat
Kind: instance method of TelegramBot
See: Telegram Bot API - getChat
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat or username of the target supergroup or channel (in the format @channelusername ) |
Retrieves an array with a list of administrators in a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - getChatAdministrators
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
Returns an integer number of members in a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - getChatMembersCount
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
Retrieves information about a member of a chat.
Kind: instance method of TelegramBot
See: Telegram Bot API - getChatMember
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
userId |
number | string
|
user identifier |
Sends answers to callback queries sent from inline keyboards.
Kind: instance method of TelegramBot
See: Telegram Bot API - answerCallbackQuery
Param | Type | Description |
---|---|---|
callbackQueryId |
number | string
|
unique callback query identifier to answer to |
options | Object |
optional parameters |
Edits text messages sent by the bot or via the bot in inline queries.
Kind: instance method of TelegramBot
See: Telegram Bot API - editMessageText
Param | Type | Description |
---|---|---|
text | string |
the new text |
options | Object |
optional parameters depending on the type of message to update |
Edits captions of messages sent by the bot or via the bot for inline bots.
Kind: instance method of TelegramBot
See: Telegram Bot API - editMessageCaption
Param | Type | Description |
---|---|---|
options | Object |
optional parameters depending on the type of message to update |
Edits only the reply markup of messages sent by the bot or via the bot for inline bots.
Kind: instance method of TelegramBot
See: Telegram Bot API - editMessageReplyMarkup
Param | Type | Description |
---|---|---|
options | Object |
optional parameters depending on the type of message to update |
Returns information about the current webhook configuration.
Kind: instance method of TelegramBot
See: Telegram Bot API - getWebhookInfo
Deletes a message after being sent.
Kind: instance method of TelegramBot
See: Telegram Bot API - deleteMessage
Param | Type | Description |
---|---|---|
chatId |
number | string
|
identifier for the target chat |
messageId |
number | string
|
identifier for the message to delete |
Restricts a user in a supergroup. The bot must be an administrator in the supergroup for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - restrictChatMember
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
userId | number |
identifier of the target user |
options | object |
optional parameters |
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - promoteChatMember
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
userId | number |
identifier of the target user |
options | object |
optional parameters |
Exports an invite link to a supergroup or a channel. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - exportChatInviteLink
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
Sets the profile photo of a chat. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - setChatPhoto
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
photo | MultipartStream |
multipart photo object |
Deletes a profile photo in a chat. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - deleteChatPhoto
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
Changes the title of a chat. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - setChatTitle
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
title | string |
the new title, between 1 and 255 characters |
Changes the description of a chat. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - setChatDescription
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
description | string |
the new description, between 1 and 255 characters |
Pins the specified message in a chat. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - pinChatMessage
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
messageId | number |
the message to pin |
options | object |
optional parameters |
Unpins the currently pinned message in a chat. The bot must be an administrator in the supergroup or channel for this to work.
Kind: instance method of TelegramBot
See: Telegram Bot API - unpinChatMessage
Param | Type | Description |
---|---|---|
chatId |
number | string
|
target chat id |
Gets the specified sticker set.
Kind: instance method of TelegramBot
See: Telegram Bot API - getStickerSet
Param | Type | Description |
---|---|---|
name | string |
the name of the sticker set |
Uploads a .png file with a sticker for later use in createNewStickerSet
and addStickerToSet
.
Kind: instance method of TelegramBot
See: Telegram Bot API - uploadStickerFile
Param | Type | Description |
---|---|---|
userId | number |
the owner |
pngSticker | MultipartStream |
multipart png sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. |
Creates a new sticker set owned by a user.
Kind: instance method of TelegramBot
See: Telegram Bot API - createNewStickerSet
Param | Type | Description |
---|---|---|
userId | number |
the owner |
name | string |
short name of whole sticker set, between 1 and 64 characters |
title | string |
title of the sticker, between 1 and 64 characters |
pngSticker | MultipartStream |
multipart png 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 |
optional parameters |
Adds a sticker to an existing set owned by a user.
Kind: instance method of TelegramBot
See: Telegram Bot API - addStickerToSet
Param | Type | Description |
---|---|---|
userId | number |
the owner |
name | string |
short name of sticker set, between 1 and 64 characters |
title | string |
title of the sticker, between 1 and 64 characters |
pngSticker | MultipartStream |
multipart png 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 |
optional parameters |
Moves a sticker in a set created by the bot to a specific position.
Kind: instance method of TelegramBot
See: Telegram Bot API - setStickerPositionInSet
Param | Type | Description |
---|---|---|
sticker | string |
file identifier of the sticker |
position | number |
zero-based position in the set |
Deletes a sticker from a set.
Kind: instance method of TelegramBot
See: Telegram Bot API - deleteStickerFromSet
Param | Type | Description |
---|---|---|
sticker | string |
file identifier of the sticker |