mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-31 22:35:38 +00:00
src: Support future additional Telegram parameters
References: * FR: https://github.com/yagop/node-telegram-bot-api/issues/454
This commit is contained in:
@@ -12,6 +12,7 @@ Added:
|
|||||||
* (#440) *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (by @kamikazechaser)
|
* (#440) *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (by @kamikazechaser)
|
||||||
1. Add `metadata` argument in `message` event (and
|
1. Add `metadata` argument in `message` event (and
|
||||||
friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
|
friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
|
||||||
|
1. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo)
|
||||||
1. Add support for Node.js v9 (by @GochoMugo)
|
1. Add support for Node.js v9 (by @GochoMugo)
|
||||||
1. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo)
|
1. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo)
|
||||||
|
|
||||||
|
137
doc/api.md
137
doc/api.md
@@ -21,10 +21,10 @@ TelegramBot
|
|||||||
* [.openWebHook()](#TelegramBot+openWebHook) ⇒ <code>Promise</code>
|
* [.openWebHook()](#TelegramBot+openWebHook) ⇒ <code>Promise</code>
|
||||||
* [.closeWebHook()](#TelegramBot+closeWebHook) ⇒ <code>Promise</code>
|
* [.closeWebHook()](#TelegramBot+closeWebHook) ⇒ <code>Promise</code>
|
||||||
* [.hasOpenWebHook()](#TelegramBot+hasOpenWebHook) ⇒ <code>Boolean</code>
|
* [.hasOpenWebHook()](#TelegramBot+hasOpenWebHook) ⇒ <code>Boolean</code>
|
||||||
* [.getMe()](#TelegramBot+getMe) ⇒ <code>Promise</code>
|
* [.getMe([options])](#TelegramBot+getMe) ⇒ <code>Promise</code>
|
||||||
* [.setWebHook(url, [options])](#TelegramBot+setWebHook) ⇒ <code>Promise</code>
|
* [.setWebHook(url, [options])](#TelegramBot+setWebHook) ⇒ <code>Promise</code>
|
||||||
* [.deleteWebHook()](#TelegramBot+deleteWebHook) ⇒ <code>Promise</code>
|
* [.deleteWebHook([options])](#TelegramBot+deleteWebHook) ⇒ <code>Promise</code>
|
||||||
* [.getWebHookInfo()](#TelegramBot+getWebHookInfo) ⇒ <code>Promise</code>
|
* [.getWebHookInfo([options])](#TelegramBot+getWebHookInfo) ⇒ <code>Promise</code>
|
||||||
* [.getUpdates([options])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
* [.getUpdates([options])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
||||||
* [.processUpdate(update)](#TelegramBot+processUpdate)
|
* [.processUpdate(update)](#TelegramBot+processUpdate)
|
||||||
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
||||||
@@ -37,18 +37,18 @@ TelegramBot
|
|||||||
* [.sendVideo(chatId, video, [options])](#TelegramBot+sendVideo) ⇒ <code>Promise</code>
|
* [.sendVideo(chatId, video, [options])](#TelegramBot+sendVideo) ⇒ <code>Promise</code>
|
||||||
* [.sendVideoNote(chatId, videoNote, [options])](#TelegramBot+sendVideoNote) ⇒ <code>Promise</code>
|
* [.sendVideoNote(chatId, videoNote, [options])](#TelegramBot+sendVideoNote) ⇒ <code>Promise</code>
|
||||||
* [.sendVoice(chatId, voice, [options])](#TelegramBot+sendVoice) ⇒ <code>Promise</code>
|
* [.sendVoice(chatId, voice, [options])](#TelegramBot+sendVoice) ⇒ <code>Promise</code>
|
||||||
* [.sendChatAction(chatId, action)](#TelegramBot+sendChatAction) ⇒ <code>Promise</code>
|
* [.sendChatAction(chatId, action, [options])](#TelegramBot+sendChatAction) ⇒ <code>Promise</code>
|
||||||
* [.kickChatMember(chatId, userId)](#TelegramBot+kickChatMember) ⇒ <code>Promise</code>
|
* [.kickChatMember(chatId, userId, [options])](#TelegramBot+kickChatMember) ⇒ <code>Promise</code>
|
||||||
* [.unbanChatMember(chatId, userId)](#TelegramBot+unbanChatMember) ⇒ <code>Promise</code>
|
* [.unbanChatMember(chatId, userId, [options])](#TelegramBot+unbanChatMember) ⇒ <code>Promise</code>
|
||||||
* [.restrictChatMember(chatId, userId, [options])](#TelegramBot+restrictChatMember) ⇒ <code>Promise</code>
|
* [.restrictChatMember(chatId, userId, [options])](#TelegramBot+restrictChatMember) ⇒ <code>Promise</code>
|
||||||
* [.promoteChatMember(chatId, userId, [options])](#TelegramBot+promoteChatMember) ⇒ <code>Promise</code>
|
* [.promoteChatMember(chatId, userId, [options])](#TelegramBot+promoteChatMember) ⇒ <code>Promise</code>
|
||||||
* [.exportChatInviteLink(chatId)](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code>
|
* [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code>
|
||||||
* [.setChatPhoto(chatId, photo)](#TelegramBot+setChatPhoto) ⇒ <code>Promise</code>
|
* [.setChatPhoto(chatId, photo, [options])](#TelegramBot+setChatPhoto) ⇒ <code>Promise</code>
|
||||||
* [.deleteChatPhoto(chatId)](#TelegramBot+deleteChatPhoto) ⇒ <code>Promise</code>
|
* [.deleteChatPhoto(chatId, [options])](#TelegramBot+deleteChatPhoto) ⇒ <code>Promise</code>
|
||||||
* [.setChatTitle(chatId, title)](#TelegramBot+setChatTitle) ⇒ <code>Promise</code>
|
* [.setChatTitle(chatId, title, [options])](#TelegramBot+setChatTitle) ⇒ <code>Promise</code>
|
||||||
* [.setChatDescription(chatId, description)](#TelegramBot+setChatDescription) ⇒ <code>Promise</code>
|
* [.setChatDescription(chatId, description, [options])](#TelegramBot+setChatDescription) ⇒ <code>Promise</code>
|
||||||
* [.pinChatMessage(chatId, messageId)](#TelegramBot+pinChatMessage) ⇒ <code>Promise</code>
|
* [.pinChatMessage(chatId, messageId, [options])](#TelegramBot+pinChatMessage) ⇒ <code>Promise</code>
|
||||||
* [.unpinChatMessage(chatId)](#TelegramBot+unpinChatMessage) ⇒ <code>Promise</code>
|
* [.unpinChatMessage(chatId, [options])](#TelegramBot+unpinChatMessage) ⇒ <code>Promise</code>
|
||||||
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
|
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
|
||||||
* [.editMessageText(text, [options])](#TelegramBot+editMessageText) ⇒ <code>Promise</code>
|
* [.editMessageText(text, [options])](#TelegramBot+editMessageText) ⇒ <code>Promise</code>
|
||||||
* [.editMessageCaption(caption, [options])](#TelegramBot+editMessageCaption) ⇒ <code>Promise</code>
|
* [.editMessageCaption(caption, [options])](#TelegramBot+editMessageCaption) ⇒ <code>Promise</code>
|
||||||
@@ -59,20 +59,20 @@ TelegramBot
|
|||||||
* [.stopMessageLiveLocation([options])](#TelegramBot+stopMessageLiveLocation) ⇒ <code>Promise</code>
|
* [.stopMessageLiveLocation([options])](#TelegramBot+stopMessageLiveLocation) ⇒ <code>Promise</code>
|
||||||
* [.sendVenue(chatId, latitude, longitude, title, address, [options])](#TelegramBot+sendVenue) ⇒ <code>Promise</code>
|
* [.sendVenue(chatId, latitude, longitude, title, address, [options])](#TelegramBot+sendVenue) ⇒ <code>Promise</code>
|
||||||
* [.sendContact(chatId, phoneNumber, firstName, [options])](#TelegramBot+sendContact) ⇒ <code>Promise</code>
|
* [.sendContact(chatId, phoneNumber, firstName, [options])](#TelegramBot+sendContact) ⇒ <code>Promise</code>
|
||||||
* [.getFile(fileId)](#TelegramBot+getFile) ⇒ <code>Promise</code>
|
* [.getFile(fileId, [options])](#TelegramBot+getFile) ⇒ <code>Promise</code>
|
||||||
* [.getFileLink(fileId)](#TelegramBot+getFileLink) ⇒ <code>Promise</code>
|
* [.getFileLink(fileId, [options])](#TelegramBot+getFileLink) ⇒ <code>Promise</code>
|
||||||
* [.downloadFile(fileId, downloadDir)](#TelegramBot+downloadFile) ⇒ <code>Promise</code>
|
* [.downloadFile(fileId, downloadDir, [options])](#TelegramBot+downloadFile) ⇒ <code>Promise</code>
|
||||||
* [.onText(regexp, callback)](#TelegramBot+onText)
|
* [.onText(regexp, callback)](#TelegramBot+onText)
|
||||||
* [.removeTextListener(regexp)](#TelegramBot+removeTextListener) ⇒ <code>Object</code>
|
* [.removeTextListener(regexp)](#TelegramBot+removeTextListener) ⇒ <code>Object</code>
|
||||||
* [.onReplyToMessage(chatId, messageId, callback)](#TelegramBot+onReplyToMessage) ⇒ <code>Number</code>
|
* [.onReplyToMessage(chatId, messageId, callback)](#TelegramBot+onReplyToMessage) ⇒ <code>Number</code>
|
||||||
* [.removeReplyListener(replyListenerId)](#TelegramBot+removeReplyListener) ⇒ <code>Object</code>
|
* [.removeReplyListener(replyListenerId)](#TelegramBot+removeReplyListener) ⇒ <code>Object</code>
|
||||||
* [.getChat(chatId)](#TelegramBot+getChat) ⇒ <code>Promise</code>
|
* [.getChat(chatId, [options])](#TelegramBot+getChat) ⇒ <code>Promise</code>
|
||||||
* [.getChatAdministrators(chatId)](#TelegramBot+getChatAdministrators) ⇒ <code>Promise</code>
|
* [.getChatAdministrators(chatId, [options])](#TelegramBot+getChatAdministrators) ⇒ <code>Promise</code>
|
||||||
* [.getChatMembersCount(chatId)](#TelegramBot+getChatMembersCount) ⇒ <code>Promise</code>
|
* [.getChatMembersCount(chatId, [options])](#TelegramBot+getChatMembersCount) ⇒ <code>Promise</code>
|
||||||
* [.getChatMember(chatId, userId)](#TelegramBot+getChatMember) ⇒ <code>Promise</code>
|
* [.getChatMember(chatId, userId, [options])](#TelegramBot+getChatMember) ⇒ <code>Promise</code>
|
||||||
* [.leaveChat(chatId)](#TelegramBot+leaveChat) ⇒ <code>Promise</code>
|
* [.leaveChat(chatId, [options])](#TelegramBot+leaveChat) ⇒ <code>Promise</code>
|
||||||
* [.setChatStickerSet(chatId, stickerSetName)](#TelegramBot+setChatStickerSet) ⇒ <code>Promise</code>
|
* [.setChatStickerSet(chatId, stickerSetName, [options])](#TelegramBot+setChatStickerSet) ⇒ <code>Promise</code>
|
||||||
* [.deleteChatStickerSet(chatId)](#TelegramBot+deleteChatStickerSet) ⇒ <code>Promise</code>
|
* [.deleteChatStickerSet(chatId, [options])](#TelegramBot+deleteChatStickerSet) ⇒ <code>Promise</code>
|
||||||
* [.sendGame(chatId, gameShortName, [options])](#TelegramBot+sendGame) ⇒ <code>Promise</code>
|
* [.sendGame(chatId, gameShortName, [options])](#TelegramBot+sendGame) ⇒ <code>Promise</code>
|
||||||
* [.setGameScore(userId, score, [options])](#TelegramBot+setGameScore) ⇒ <code>Promise</code>
|
* [.setGameScore(userId, score, [options])](#TelegramBot+setGameScore) ⇒ <code>Promise</code>
|
||||||
* [.getGameHighScores(userId, [options])](#TelegramBot+getGameHighScores) ⇒ <code>Promise</code>
|
* [.getGameHighScores(userId, [options])](#TelegramBot+getGameHighScores) ⇒ <code>Promise</code>
|
||||||
@@ -84,8 +84,8 @@ TelegramBot
|
|||||||
* [.uploadStickerFile(userId, pngSticker, [options])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
|
* [.uploadStickerFile(userId, pngSticker, [options])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
|
||||||
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
|
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
|
||||||
* [.addStickerToSet(userId, name, pngSticker, emojis, [options])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
|
* [.addStickerToSet(userId, name, pngSticker, emojis, [options])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
|
||||||
* [.setStickerPositionInSet(sticker, position)](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code>
|
* [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code>
|
||||||
* [.deleteStickerFromSet(sticker)](#TelegramBot+deleteStickerFromSet) ⇒ <code>Promise</code>
|
* [.deleteStickerFromSet(sticker, [options])](#TelegramBot+deleteStickerFromSet) ⇒ <code>Promise</code>
|
||||||
* _static_
|
* _static_
|
||||||
* [.errors](#TelegramBot.errors) : <code>Object</code>
|
* [.errors](#TelegramBot.errors) : <code>Object</code>
|
||||||
* [.messageTypes](#TelegramBot.messageTypes) : <code>Array.<String></code>
|
* [.messageTypes](#TelegramBot.messageTypes) : <code>Array.<String></code>
|
||||||
@@ -206,11 +206,16 @@ Otherwise, false.
|
|||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
<a name="TelegramBot+getMe"></a>
|
<a name="TelegramBot+getMe"></a>
|
||||||
|
|
||||||
### telegramBot.getMe() ⇒ <code>Promise</code>
|
### telegramBot.getMe([options]) ⇒ <code>Promise</code>
|
||||||
Returns basic information about the bot in form of a `User` object.
|
Returns basic information about the bot in form of a `User` object.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
**See**: https://core.telegram.org/bots/api#getme
|
**See**: https://core.telegram.org/bots/api#getme
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setWebHook"></a>
|
<a name="TelegramBot+setWebHook"></a>
|
||||||
|
|
||||||
### telegramBot.setWebHook(url, [options]) ⇒ <code>Promise</code>
|
### telegramBot.setWebHook(url, [options]) ⇒ <code>Promise</code>
|
||||||
@@ -229,15 +234,20 @@ that is being deprecated.
|
|||||||
|
|
||||||
<a name="TelegramBot+deleteWebHook"></a>
|
<a name="TelegramBot+deleteWebHook"></a>
|
||||||
|
|
||||||
### telegramBot.deleteWebHook() ⇒ <code>Promise</code>
|
### telegramBot.deleteWebHook([options]) ⇒ <code>Promise</code>
|
||||||
Use this method to remove webhook integration if you decide to
|
Use this method to remove webhook integration if you decide to
|
||||||
switch back to getUpdates. Returns True on success.
|
switch back to getUpdates. Returns True on success.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
**See**: https://core.telegram.org/bots/api#deletewebhook
|
**See**: https://core.telegram.org/bots/api#deletewebhook
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getWebHookInfo"></a>
|
<a name="TelegramBot+getWebHookInfo"></a>
|
||||||
|
|
||||||
### telegramBot.getWebHookInfo() ⇒ <code>Promise</code>
|
### telegramBot.getWebHookInfo([options]) ⇒ <code>Promise</code>
|
||||||
Use this method to get current webhook status.
|
Use this method to get current webhook status.
|
||||||
On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
|
On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
|
||||||
If the bot is using getUpdates, will return an object with the
|
If the bot is using getUpdates, will return an object with the
|
||||||
@@ -245,6 +255,11 @@ url field empty.
|
|||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
**See**: https://core.telegram.org/bots/api#getwebhookinfo
|
**See**: https://core.telegram.org/bots/api#getwebhookinfo
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getUpdates"></a>
|
<a name="TelegramBot+getUpdates"></a>
|
||||||
|
|
||||||
### telegramBot.getUpdates([options]) ⇒ <code>Promise</code>
|
### telegramBot.getUpdates([options]) ⇒ <code>Promise</code>
|
||||||
@@ -417,7 +432,7 @@ Send voice
|
|||||||
|
|
||||||
<a name="TelegramBot+sendChatAction"></a>
|
<a name="TelegramBot+sendChatAction"></a>
|
||||||
|
|
||||||
### telegramBot.sendChatAction(chatId, action) ⇒ <code>Promise</code>
|
### telegramBot.sendChatAction(chatId, action, [options]) ⇒ <code>Promise</code>
|
||||||
Send chat action.
|
Send chat action.
|
||||||
`typing` for text messages,
|
`typing` for text messages,
|
||||||
`upload_photo` for photos, `record_video` or `upload_video` for videos,
|
`upload_photo` for photos, `record_video` or `upload_video` for videos,
|
||||||
@@ -431,10 +446,11 @@ Send chat action.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
| action | <code>String</code> | Type of action to broadcast. |
|
| action | <code>String</code> | Type of action to broadcast. |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+kickChatMember"></a>
|
<a name="TelegramBot+kickChatMember"></a>
|
||||||
|
|
||||||
### telegramBot.kickChatMember(chatId, userId) ⇒ <code>Promise</code>
|
### telegramBot.kickChatMember(chatId, userId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to kick a user from a group or a supergroup.
|
Use this method to kick a user from a group or a supergroup.
|
||||||
In the case of supergroups, the user will not be able to return
|
In the case of supergroups, the user will not be able to return
|
||||||
to the group on their own using invite links, etc., unless unbanned
|
to the group on their own using invite links, etc., unless unbanned
|
||||||
@@ -448,10 +464,11 @@ Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
| userId | <code>Number</code> | Unique identifier of the target user |
|
| userId | <code>Number</code> | Unique identifier of the target user |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+unbanChatMember"></a>
|
<a name="TelegramBot+unbanChatMember"></a>
|
||||||
|
|
||||||
### telegramBot.unbanChatMember(chatId, userId) ⇒ <code>Promise</code>
|
### telegramBot.unbanChatMember(chatId, userId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to unban a previously kicked user in a supergroup.
|
Use this method to unban a previously kicked user in a supergroup.
|
||||||
The user will not return to the group automatically, but will be
|
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
|
able to join via link, etc. The bot must be an administrator in
|
||||||
@@ -464,6 +481,7 @@ the group for this to work. Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
| userId | <code>Number</code> | Unique identifier of the target user |
|
| userId | <code>Number</code> | Unique identifier of the target user |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+restrictChatMember"></a>
|
<a name="TelegramBot+restrictChatMember"></a>
|
||||||
|
|
||||||
@@ -501,7 +519,7 @@ Returns True on success.
|
|||||||
|
|
||||||
<a name="TelegramBot+exportChatInviteLink"></a>
|
<a name="TelegramBot+exportChatInviteLink"></a>
|
||||||
|
|
||||||
### telegramBot.exportChatInviteLink(chatId) ⇒ <code>Promise</code>
|
### telegramBot.exportChatInviteLink(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to export an invite link to a supergroup or a channel.
|
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.
|
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.
|
Returns exported invite link as String on success.
|
||||||
@@ -512,10 +530,11 @@ Returns exported invite link as String on success.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target chat or username of the target supergroup |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target chat or username of the target supergroup |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setChatPhoto"></a>
|
<a name="TelegramBot+setChatPhoto"></a>
|
||||||
|
|
||||||
### telegramBot.setChatPhoto(chatId, photo) ⇒ <code>Promise</code>
|
### telegramBot.setChatPhoto(chatId, photo, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
|
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
|
||||||
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
@@ -527,10 +546,11 @@ Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
| photo | <code>stream.Stream</code> | <code>Buffer</code> | A file path or a Stream. |
|
| photo | <code>stream.Stream</code> | <code>Buffer</code> | A file path or a Stream. |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+deleteChatPhoto"></a>
|
<a name="TelegramBot+deleteChatPhoto"></a>
|
||||||
|
|
||||||
### telegramBot.deleteChatPhoto(chatId) ⇒ <code>Promise</code>
|
### telegramBot.deleteChatPhoto(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to delete a chat photo. Photos can't be changed for private chats.
|
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.
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
@@ -541,10 +561,11 @@ Returns True on success.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setChatTitle"></a>
|
<a name="TelegramBot+setChatTitle"></a>
|
||||||
|
|
||||||
### telegramBot.setChatTitle(chatId, title) ⇒ <code>Promise</code>
|
### telegramBot.setChatTitle(chatId, title, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to change the title of a chat. Titles can't be changed for private chats.
|
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.
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
@@ -556,10 +577,11 @@ Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
| title | <code>String</code> | New chat title, 1-255 characters |
|
| title | <code>String</code> | New chat title, 1-255 characters |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setChatDescription"></a>
|
<a name="TelegramBot+setChatDescription"></a>
|
||||||
|
|
||||||
### telegramBot.setChatDescription(chatId, description) ⇒ <code>Promise</code>
|
### telegramBot.setChatDescription(chatId, description, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to change the description of a supergroup or a channel.
|
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.
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
@@ -571,10 +593,11 @@ Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
| description | <code>String</code> | New chat title, 1-255 characters |
|
| description | <code>String</code> | New chat title, 1-255 characters |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+pinChatMessage"></a>
|
<a name="TelegramBot+pinChatMessage"></a>
|
||||||
|
|
||||||
### telegramBot.pinChatMessage(chatId, messageId) ⇒ <code>Promise</code>
|
### telegramBot.pinChatMessage(chatId, messageId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to pin a message in a supergroup.
|
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.
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
@@ -586,10 +609,11 @@ Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
| messageId | <code>String</code> | Identifier of a message to pin |
|
| messageId | <code>String</code> | Identifier of a message to pin |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+unpinChatMessage"></a>
|
<a name="TelegramBot+unpinChatMessage"></a>
|
||||||
|
|
||||||
### telegramBot.unpinChatMessage(chatId) ⇒ <code>Promise</code>
|
### telegramBot.unpinChatMessage(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to unpin a message in a supergroup chat.
|
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.
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
@@ -600,6 +624,7 @@ Returns True on success.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+answerCallbackQuery"></a>
|
<a name="TelegramBot+answerCallbackQuery"></a>
|
||||||
|
|
||||||
@@ -776,7 +801,7 @@ Use this method to send phone contacts.
|
|||||||
|
|
||||||
<a name="TelegramBot+getFile"></a>
|
<a name="TelegramBot+getFile"></a>
|
||||||
|
|
||||||
### telegramBot.getFile(fileId) ⇒ <code>Promise</code>
|
### telegramBot.getFile(fileId, [options]) ⇒ <code>Promise</code>
|
||||||
Get file.
|
Get file.
|
||||||
Use this method to get basic info about a file and prepare it for downloading.
|
Use this method to get basic info about a file and prepare it for downloading.
|
||||||
Attention: link will be valid for 1 hour.
|
Attention: link will be valid for 1 hour.
|
||||||
@@ -787,10 +812,11 @@ Attention: link will be valid for 1 hour.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| fileId | <code>String</code> | File identifier to get info about |
|
| fileId | <code>String</code> | File identifier to get info about |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getFileLink"></a>
|
<a name="TelegramBot+getFileLink"></a>
|
||||||
|
|
||||||
### telegramBot.getFileLink(fileId) ⇒ <code>Promise</code>
|
### telegramBot.getFileLink(fileId, [options]) ⇒ <code>Promise</code>
|
||||||
Get link for file.
|
Get link for file.
|
||||||
Use this method to get link for file for subsequent use.
|
Use this method to get link for file for subsequent use.
|
||||||
Attention: link will be valid for 1 hour.
|
Attention: link will be valid for 1 hour.
|
||||||
@@ -805,10 +831,11 @@ which returns just path to file on remote server (you will have to manually buil
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| fileId | <code>String</code> | File identifier to get info about |
|
| fileId | <code>String</code> | File identifier to get info about |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+downloadFile"></a>
|
<a name="TelegramBot+downloadFile"></a>
|
||||||
|
|
||||||
### telegramBot.downloadFile(fileId, downloadDir) ⇒ <code>Promise</code>
|
### telegramBot.downloadFile(fileId, downloadDir, [options]) ⇒ <code>Promise</code>
|
||||||
Downloads file in the specified folder.
|
Downloads file in the specified folder.
|
||||||
This is just a sugar for (getFile)[#getfilefiled] method
|
This is just a sugar for (getFile)[#getfilefiled] method
|
||||||
|
|
||||||
@@ -819,6 +846,7 @@ This is just a sugar for (getFile)[#getfilefiled] method
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| fileId | <code>String</code> | File identifier to get info about |
|
| fileId | <code>String</code> | File identifier to get info about |
|
||||||
| downloadDir | <code>String</code> | Absolute path to the folder in which file will be saved |
|
| downloadDir | <code>String</code> | Absolute path to the folder in which file will be saved |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+onText"></a>
|
<a name="TelegramBot+onText"></a>
|
||||||
|
|
||||||
@@ -876,7 +904,7 @@ Removes a reply that has been prev. registered for a message response.
|
|||||||
|
|
||||||
<a name="TelegramBot+getChat"></a>
|
<a name="TelegramBot+getChat"></a>
|
||||||
|
|
||||||
### telegramBot.getChat(chatId) ⇒ <code>Promise</code>
|
### telegramBot.getChat(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to get up to date information about the chat
|
Use this method to get up to date information about the chat
|
||||||
(current name of the user for one-on-one conversations, current
|
(current name of the user for one-on-one conversations, current
|
||||||
username of a user, group or channel, etc.).
|
username of a user, group or channel, etc.).
|
||||||
@@ -887,10 +915,11 @@ username of a user, group or channel, etc.).
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target chat or username of the target supergroup or channel |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target chat or username of the target supergroup or channel |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getChatAdministrators"></a>
|
<a name="TelegramBot+getChatAdministrators"></a>
|
||||||
|
|
||||||
### telegramBot.getChatAdministrators(chatId) ⇒ <code>Promise</code>
|
### telegramBot.getChatAdministrators(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Returns the administrators in a chat in form of an Array of `ChatMember` objects.
|
Returns the administrators in a chat in form of an Array of `ChatMember` objects.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
@@ -899,10 +928,11 @@ Returns the administrators in a chat in form of an Array of `ChatMember` objects
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getChatMembersCount"></a>
|
<a name="TelegramBot+getChatMembersCount"></a>
|
||||||
|
|
||||||
### telegramBot.getChatMembersCount(chatId) ⇒ <code>Promise</code>
|
### telegramBot.getChatMembersCount(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to get the number of members in a chat.
|
Use this method to get the number of members in a chat.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
@@ -911,10 +941,11 @@ Use this method to get the number of members in a chat.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getChatMember"></a>
|
<a name="TelegramBot+getChatMember"></a>
|
||||||
|
|
||||||
### telegramBot.getChatMember(chatId, userId) ⇒ <code>Promise</code>
|
### telegramBot.getChatMember(chatId, userId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to get information about a member of a chat.
|
Use this method to get information about a member of a chat.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
@@ -924,10 +955,11 @@ Use this method to get information about a member of a chat.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
| userId | <code>Number</code> | Unique identifier of the target user |
|
| userId | <code>Number</code> | Unique identifier of the target user |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+leaveChat"></a>
|
<a name="TelegramBot+leaveChat"></a>
|
||||||
|
|
||||||
### telegramBot.leaveChat(chatId) ⇒ <code>Promise</code>
|
### telegramBot.leaveChat(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Leave a group, supergroup or channel.
|
Leave a group, supergroup or channel.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
@@ -936,10 +968,11 @@ Leave a group, supergroup or channel.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setChatStickerSet"></a>
|
<a name="TelegramBot+setChatStickerSet"></a>
|
||||||
|
|
||||||
### telegramBot.setChatStickerSet(chatId, stickerSetName) ⇒ <code>Promise</code>
|
### telegramBot.setChatStickerSet(chatId, stickerSetName, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to set a new group sticker set for a supergroup.
|
Use this method to set a new group sticker set for a supergroup.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
@@ -949,10 +982,11 @@ Use this method to set a new group sticker set for a supergroup.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||||
| stickerSetName | <code>String</code> | Name of the sticker set to be set as the group sticker set |
|
| stickerSetName | <code>String</code> | Name of the sticker set to be set as the group sticker set |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+deleteChatStickerSet"></a>
|
<a name="TelegramBot+deleteChatStickerSet"></a>
|
||||||
|
|
||||||
### telegramBot.deleteChatStickerSet(chatId) ⇒ <code>Promise</code>
|
### telegramBot.deleteChatStickerSet(chatId, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to delete a group sticker set from a supergroup.
|
Use this method to delete a group sticker set from a supergroup.
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
@@ -961,6 +995,7 @@ Use this method to delete a group sticker set from a supergroup.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+sendGame"></a>
|
<a name="TelegramBot+sendGame"></a>
|
||||||
|
|
||||||
@@ -1142,7 +1177,7 @@ Returns True on success.
|
|||||||
|
|
||||||
<a name="TelegramBot+setStickerPositionInSet"></a>
|
<a name="TelegramBot+setStickerPositionInSet"></a>
|
||||||
|
|
||||||
### telegramBot.setStickerPositionInSet(sticker, position) ⇒ <code>Promise</code>
|
### telegramBot.setStickerPositionInSet(sticker, position, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to move a sticker in a set created by the bot to a specific position.
|
Use this method to move a sticker in a set created by the bot to a specific position.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
|
|
||||||
@@ -1157,10 +1192,11 @@ Returns True on success.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| sticker | <code>String</code> | File identifier of the sticker |
|
| sticker | <code>String</code> | File identifier of the sticker |
|
||||||
| position | <code>Number</code> | New sticker position in the set, zero-based |
|
| position | <code>Number</code> | New sticker position in the set, zero-based |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+deleteStickerFromSet"></a>
|
<a name="TelegramBot+deleteStickerFromSet"></a>
|
||||||
|
|
||||||
### telegramBot.deleteStickerFromSet(sticker) ⇒ <code>Promise</code>
|
### telegramBot.deleteStickerFromSet(sticker, [options]) ⇒ <code>Promise</code>
|
||||||
Use this method to delete a sticker from a set created by the bot.
|
Use this method to delete a sticker from a set created by the bot.
|
||||||
Returns True on success.
|
Returns True on success.
|
||||||
|
|
||||||
@@ -1174,6 +1210,7 @@ Returns True on success.
|
|||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| sticker | <code>String</code> | File identifier of the sticker |
|
| sticker | <code>String</code> | File identifier of the sticker |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot.errors"></a>
|
<a name="TelegramBot.errors"></a>
|
||||||
|
|
||||||
|
134
src/telegram.js
134
src/telegram.js
@@ -416,12 +416,12 @@ class TelegramBot extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns basic information about the bot in form of a `User` object.
|
* Returns basic information about the bot in form of a `User` object.
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getme
|
* @see https://core.telegram.org/bots/api#getme
|
||||||
*/
|
*/
|
||||||
getMe() {
|
getMe(form = {}) {
|
||||||
const _path = 'getMe';
|
return this._request('getMe', { form });
|
||||||
return this._request(_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -471,11 +471,12 @@ class TelegramBot extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Use this method to remove webhook integration if you decide to
|
* Use this method to remove webhook integration if you decide to
|
||||||
* switch back to getUpdates. Returns True on success.
|
* switch back to getUpdates. Returns True on success.
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#deletewebhook
|
* @see https://core.telegram.org/bots/api#deletewebhook
|
||||||
*/
|
*/
|
||||||
deleteWebHook() {
|
deleteWebHook(form = {}) {
|
||||||
return this._request('deleteWebhook');
|
return this._request('deleteWebhook', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -483,11 +484,12 @@ class TelegramBot extends EventEmitter {
|
|||||||
* On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
|
* On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
|
||||||
* If the bot is using getUpdates, will return an object with the
|
* If the bot is using getUpdates, will return an object with the
|
||||||
* url field empty.
|
* url field empty.
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getwebhookinfo
|
* @see https://core.telegram.org/bots/api#getwebhookinfo
|
||||||
*/
|
*/
|
||||||
getWebHookInfo() {
|
getWebHookInfo(form = {}) {
|
||||||
return this._request('getWebhookInfo');
|
return this._request('getWebhookInfo', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -842,14 +844,13 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
* @param {String} action Type of action to broadcast.
|
* @param {String} action Type of action to broadcast.
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#sendchataction
|
* @see https://core.telegram.org/bots/api#sendchataction
|
||||||
*/
|
*/
|
||||||
sendChatAction(chatId, action) {
|
sendChatAction(chatId, action, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
action,
|
form.action = action;
|
||||||
chat_id: chatId
|
|
||||||
};
|
|
||||||
return this._request('sendChatAction', { form });
|
return this._request('sendChatAction', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -862,14 +863,13 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
* @param {Number} userId Unique identifier of the target user
|
* @param {Number} userId Unique identifier of the target user
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#kickchatmember
|
* @see https://core.telegram.org/bots/api#kickchatmember
|
||||||
*/
|
*/
|
||||||
kickChatMember(chatId, userId) {
|
kickChatMember(chatId, userId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId,
|
form.user_id = userId;
|
||||||
user_id: userId
|
|
||||||
};
|
|
||||||
return this._request('kickChatMember', { form });
|
return this._request('kickChatMember', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,14 +881,13 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
* @param {Number} userId Unique identifier of the target user
|
* @param {Number} userId Unique identifier of the target user
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#unbanchatmember
|
* @see https://core.telegram.org/bots/api#unbanchatmember
|
||||||
*/
|
*/
|
||||||
unbanChatMember(chatId, userId) {
|
unbanChatMember(chatId, userId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId,
|
form.user_id = userId;
|
||||||
user_id: userId
|
|
||||||
};
|
|
||||||
return this._request('unbanChatMember', { form });
|
return this._request('unbanChatMember', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,6 +933,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Returns exported invite link as String on success.
|
* Returns exported invite link as String on success.
|
||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup
|
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#exportchatinvitelink
|
* @see https://core.telegram.org/bots/api#exportchatinvitelink
|
||||||
*/
|
*/
|
||||||
@@ -949,6 +949,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
* @param {stream.Stream|Buffer} photo A file path or a Stream.
|
* @param {stream.Stream|Buffer} photo A file path or a Stream.
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#setchatphoto
|
* @see https://core.telegram.org/bots/api#setchatphoto
|
||||||
*/
|
*/
|
||||||
@@ -973,6 +974,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Returns True on success.
|
* Returns True on success.
|
||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#deletechatphoto
|
* @see https://core.telegram.org/bots/api#deletechatphoto
|
||||||
*/
|
*/
|
||||||
@@ -988,6 +990,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
* @param {String} title New chat title, 1-255 characters
|
* @param {String} title New chat title, 1-255 characters
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#setchattitle
|
* @see https://core.telegram.org/bots/api#setchattitle
|
||||||
*/
|
*/
|
||||||
@@ -1004,6 +1007,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
* @param {String} description New chat title, 1-255 characters
|
* @param {String} description New chat title, 1-255 characters
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#setchatdescription
|
* @see https://core.telegram.org/bots/api#setchatdescription
|
||||||
*/
|
*/
|
||||||
@@ -1020,6 +1024,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
* @param {String} messageId Identifier of a message to pin
|
* @param {String} messageId Identifier of a message to pin
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#pinchatmessage
|
* @see https://core.telegram.org/bots/api#pinchatmessage
|
||||||
*/
|
*/
|
||||||
@@ -1035,6 +1040,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Returns True on success.
|
* Returns True on success.
|
||||||
*
|
*
|
||||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#unpinchatmessage
|
* @see https://core.telegram.org/bots/api#unpinchatmessage
|
||||||
*/
|
*/
|
||||||
@@ -1266,11 +1272,12 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Attention: link will be valid for 1 hour.
|
* Attention: link will be valid for 1 hour.
|
||||||
*
|
*
|
||||||
* @param {String} fileId File identifier to get info about
|
* @param {String} fileId File identifier to get info about
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getfile
|
* @see https://core.telegram.org/bots/api#getfile
|
||||||
*/
|
*/
|
||||||
getFile(fileId) {
|
getFile(fileId, form = {}) {
|
||||||
const form = { file_id: fileId };
|
form.file_id = fileId;
|
||||||
return this._request('getFile', { form });
|
return this._request('getFile', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1283,11 +1290,12 @@ class TelegramBot extends EventEmitter {
|
|||||||
* which returns just path to file on remote server (you will have to manually build full uri after that).
|
* which returns just path to file on remote server (you will have to manually build full uri after that).
|
||||||
*
|
*
|
||||||
* @param {String} fileId File identifier to get info about
|
* @param {String} fileId File identifier to get info about
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise} promise Promise which will have *fileURI* in resolve callback
|
* @return {Promise} promise Promise which will have *fileURI* in resolve callback
|
||||||
* @see https://core.telegram.org/bots/api#getfile
|
* @see https://core.telegram.org/bots/api#getfile
|
||||||
*/
|
*/
|
||||||
getFileLink(fileId) {
|
getFileLink(fileId, form = {}) {
|
||||||
return this.getFile(fileId)
|
return this.getFile(fileId, form)
|
||||||
.then(resp => `${this.options.baseApiUrl}/file/bot${this.token}/${resp.file_path}`);
|
.then(resp => `${this.options.baseApiUrl}/file/bot${this.token}/${resp.file_path}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1297,11 +1305,12 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {String} fileId File identifier to get info about
|
* @param {String} fileId File identifier to get info about
|
||||||
* @param {String} downloadDir Absolute path to the folder in which file will be saved
|
* @param {String} downloadDir Absolute path to the folder in which file will be saved
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise} promise Promise, which will have *filePath* of downloaded file in resolve callback
|
* @return {Promise} promise Promise, which will have *filePath* of downloaded file in resolve callback
|
||||||
*/
|
*/
|
||||||
downloadFile(fileId, downloadDir) {
|
downloadFile(fileId, downloadDir, form = {}) {
|
||||||
return this
|
return this
|
||||||
.getFileLink(fileId)
|
.getFileLink(fileId, form)
|
||||||
.then(fileURI => {
|
.then(fileURI => {
|
||||||
const fileName = fileURI.slice(fileURI.lastIndexOf('/') + 1);
|
const fileName = fileURI.slice(fileURI.lastIndexOf('/') + 1);
|
||||||
// TODO: Ensure fileName doesn't contains slashes
|
// TODO: Ensure fileName doesn't contains slashes
|
||||||
@@ -1384,39 +1393,36 @@ class TelegramBot extends EventEmitter {
|
|||||||
* (current name of the user for one-on-one conversations, current
|
* (current name of the user for one-on-one conversations, current
|
||||||
* username of a user, group or channel, etc.).
|
* username of a user, group or channel, etc.).
|
||||||
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup or channel
|
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup or channel
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getchat
|
* @see https://core.telegram.org/bots/api#getchat
|
||||||
*/
|
*/
|
||||||
getChat(chatId) {
|
getChat(chatId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId
|
|
||||||
};
|
|
||||||
return this._request('getChat', { form });
|
return this._request('getChat', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the administrators in a chat in form of an Array of `ChatMember` objects.
|
* Returns the administrators in a chat in form of an Array of `ChatMember` objects.
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getchatadministrators
|
* @see https://core.telegram.org/bots/api#getchatadministrators
|
||||||
*/
|
*/
|
||||||
getChatAdministrators(chatId) {
|
getChatAdministrators(chatId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId
|
|
||||||
};
|
|
||||||
return this._request('getChatAdministrators', { form });
|
return this._request('getChatAdministrators', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method to get the number of members in a chat.
|
* Use this method to get the number of members in a chat.
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getchatmemberscount
|
* @see https://core.telegram.org/bots/api#getchatmemberscount
|
||||||
*/
|
*/
|
||||||
getChatMembersCount(chatId) {
|
getChatMembersCount(chatId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId
|
|
||||||
};
|
|
||||||
return this._request('getChatMembersCount', { form });
|
return this._request('getChatMembersCount', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1424,27 +1430,25 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Use this method to get information about a member of a chat.
|
* Use this method to get information about a member of a chat.
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
* @param {Number} userId Unique identifier of the target user
|
* @param {Number} userId Unique identifier of the target user
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getchatmember
|
* @see https://core.telegram.org/bots/api#getchatmember
|
||||||
*/
|
*/
|
||||||
getChatMember(chatId, userId) {
|
getChatMember(chatId, userId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId,
|
form.user_id = userId;
|
||||||
user_id: userId
|
|
||||||
};
|
|
||||||
return this._request('getChatMember', { form });
|
return this._request('getChatMember', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leave a group, supergroup or channel.
|
* Leave a group, supergroup or channel.
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#leavechat
|
* @see https://core.telegram.org/bots/api#leavechat
|
||||||
*/
|
*/
|
||||||
leaveChat(chatId) {
|
leaveChat(chatId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId
|
|
||||||
};
|
|
||||||
return this._request('leaveChat', { form });
|
return this._request('leaveChat', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1452,27 +1456,25 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Use this method to set a new group sticker set for a supergroup.
|
* Use this method to set a new group sticker set for a supergroup.
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||||
* @param {String} stickerSetName Name of the sticker set to be set as the group sticker set
|
* @param {String} stickerSetName Name of the sticker set to be set as the group sticker set
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#setchatstickerset
|
* @see https://core.telegram.org/bots/api#setchatstickerset
|
||||||
*/
|
*/
|
||||||
setChatStickerSet(chatId, stickerSetName) {
|
setChatStickerSet(chatId, stickerSetName, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId,
|
form.sticker_set_name = stickerSetName;
|
||||||
sticker_set_name: stickerSetName
|
|
||||||
};
|
|
||||||
return this._request('setChatStickerSet', { form });
|
return this._request('setChatStickerSet', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method to delete a group sticker set from a supergroup.
|
* Use this method to delete a group sticker set from a supergroup.
|
||||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#deletechatstickerset
|
* @see https://core.telegram.org/bots/api#deletechatstickerset
|
||||||
*/
|
*/
|
||||||
deleteChatStickerSet(chatId) {
|
deleteChatStickerSet(chatId, form = {}) {
|
||||||
const form = {
|
form.chat_id = chatId;
|
||||||
chat_id: chatId
|
|
||||||
};
|
|
||||||
return this._request('deleteChatStickerSet', { form });
|
return this._request('deleteChatStickerSet', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1703,15 +1705,14 @@ class TelegramBot extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @param {String} sticker File identifier of the sticker
|
* @param {String} sticker File identifier of the sticker
|
||||||
* @param {Number} position New sticker position in the set, zero-based
|
* @param {Number} position New sticker position in the set, zero-based
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#setstickerpositioninset
|
* @see https://core.telegram.org/bots/api#setstickerpositioninset
|
||||||
* @todo Add tests for this method!
|
* @todo Add tests for this method!
|
||||||
*/
|
*/
|
||||||
setStickerPositionInSet(sticker, position) {
|
setStickerPositionInSet(sticker, position, form = {}) {
|
||||||
const form = {
|
form.sticker = sticker;
|
||||||
sticker,
|
form.position = position;
|
||||||
position,
|
|
||||||
};
|
|
||||||
return this._request('setStickerPositionInSet', { form });
|
return this._request('setStickerPositionInSet', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1720,14 +1721,13 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Returns True on success.
|
* Returns True on success.
|
||||||
*
|
*
|
||||||
* @param {String} sticker File identifier of the sticker
|
* @param {String} sticker File identifier of the sticker
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#deletestickerfromset
|
* @see https://core.telegram.org/bots/api#deletestickerfromset
|
||||||
* @todo Add tests for this method!
|
* @todo Add tests for this method!
|
||||||
*/
|
*/
|
||||||
deleteStickerFromSet(sticker) {
|
deleteStickerFromSet(sticker, form = {}) {
|
||||||
const form = {
|
form.sticker = sticker;
|
||||||
sticker,
|
|
||||||
};
|
|
||||||
return this._request('deleteStickerFromSet', { form });
|
return this._request('deleteStickerFromSet', { form });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user