mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-23 18:38:01 +00:00
Merge pull request #922 from danielperez9430/master
Telegram Bot API 5.5 Support
This commit is contained in:
commit
e114682f2e
13
CHANGELOG.md
13
CHANGELOG.md
@ -3,6 +3,19 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [0.56.0][0.56.0] - 2021-12-07
|
||||||
|
|
||||||
|
Added:
|
||||||
|
|
||||||
|
1. Support Bot API v5.5: (@danielperez9430)
|
||||||
|
|
||||||
|
* Add method *banChatSenderChat()*
|
||||||
|
* Add method *unbanChatSenderChat()*
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
* Tests for support with new invite link format
|
||||||
|
|
||||||
## [0.55.0][0.55.0] - 2021-11-06
|
## [0.55.0][0.55.0] - 2021-11-06
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
|
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
|
|
||||||
[](https://core.telegram.org/bots/api)
|
[](https://core.telegram.org/bots/api)
|
||||||
[](https://www.npmjs.org/package/node-telegram-bot-api)
|
[](https://www.npmjs.org/package/node-telegram-bot-api)
|
||||||
[](https://travis-ci.org/yagop/node-telegram-bot-api)
|
[](https://travis-ci.org/yagop/node-telegram-bot-api)
|
||||||
[](https://codecov.io/gh/yagop/node-telegram-bot-api)
|
[](https://codecov.io/gh/yagop/node-telegram-bot-api)
|
||||||
|
40
doc/api.md
40
doc/api.md
@ -49,6 +49,8 @@ TelegramBot
|
|||||||
* [.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>
|
||||||
* [.setChatAdministratorCustomTitle(chatId, userId, customTitle, [options])](#TelegramBot+setChatAdministratorCustomTitle) ⇒ <code>Promise</code>
|
* [.setChatAdministratorCustomTitle(chatId, userId, customTitle, [options])](#TelegramBot+setChatAdministratorCustomTitle) ⇒ <code>Promise</code>
|
||||||
|
* [.banChatSenderChat(chatId, senderChatId, [options])](#TelegramBot+banChatSenderChat) ⇒ <code>Boolean</code>
|
||||||
|
* [.unbanChatSenderChat(chatId, senderChatId, [options])](#TelegramBot+unbanChatSenderChat) ⇒ <code>Boolean</code>
|
||||||
* [.setChatPermissions(chatId, chatPermissions, [options])](#TelegramBot+setChatPermissions) ⇒ <code>Promise</code>
|
* [.setChatPermissions(chatId, chatPermissions, [options])](#TelegramBot+setChatPermissions) ⇒ <code>Promise</code>
|
||||||
* [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code>
|
* [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code>
|
||||||
* [.createChatInviteLink(chatId, [options])](#TelegramBot+createChatInviteLink) ⇒ <code>Object</code>
|
* [.createChatInviteLink(chatId, [options])](#TelegramBot+createChatInviteLink) ⇒ <code>Object</code>
|
||||||
@ -703,6 +705,41 @@ Returns True on success.
|
|||||||
| customTitle | <code>String</code> | New custom title for the administrator; 0-16 characters, emoji are not allowed |
|
| customTitle | <code>String</code> | New custom title for the administrator; 0-16 characters, emoji are not allowed |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+banChatSenderChat"></a>
|
||||||
|
|
||||||
|
### telegramBot.banChatSenderChat(chatId, senderChatId, [options]) ⇒ <code>Boolean</code>
|
||||||
|
Use this method to ban a channel chat in a supergroup or a channel.
|
||||||
|
The owner of the chat will not be able to send messages and join live streams
|
||||||
|
on behalf of the chat, unless it is unbanned first.
|
||||||
|
The bot must be an administrator in the supergroup or channel for this to work
|
||||||
|
and must have the appropriate administrator rights.
|
||||||
|
Returns True on success.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
|
**See**: https://core.telegram.org/bots/api#banchatsenderchat
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
|
| senderChatId | <code>Number</code> | Unique identifier of the target user |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+unbanChatSenderChat"></a>
|
||||||
|
|
||||||
|
### telegramBot.unbanChatSenderChat(chatId, senderChatId, [options]) ⇒ <code>Boolean</code>
|
||||||
|
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.
|
||||||
|
Returns True on success.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
|
**See**: https://core.telegram.org/bots/api#unbanchatsenderchat
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup |
|
||||||
|
| senderChatId | <code>Number</code> | Unique identifier of the target user |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setChatPermissions"></a>
|
<a name="TelegramBot+setChatPermissions"></a>
|
||||||
|
|
||||||
### telegramBot.setChatPermissions(chatId, chatPermissions, [options]) ⇒ <code>Promise</code>
|
### telegramBot.setChatPermissions(chatId, chatPermissions, [options]) ⇒ <code>Promise</code>
|
||||||
@ -1032,8 +1069,7 @@ Otherwise, message type can be changed arbitrarily. When inline message is edite
|
|||||||
Use previously uploaded file via its file_id or specify a URL.
|
Use previously uploaded file via its file_id or specify a URL.
|
||||||
On success, the edited Message is returned.
|
On success, the edited Message is returned.
|
||||||
|
|
||||||
Note that you must provide one of chat_id, message_id, or
|
Note that you must provide one of chat_id, message_id, or inline_message_id in your request.
|
||||||
inline_message_id in your request.
|
|
||||||
|
|
||||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
**See**: https://core.telegram.org/bots/api#editmessagemedia
|
**See**: https://core.telegram.org/bots/api#editmessagemedia
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-telegram-bot-api",
|
"name": "node-telegram-bot-api",
|
||||||
"version": "0.55.0",
|
"version": "0.56.0",
|
||||||
"description": "Telegram Bot API",
|
"description": "Telegram Bot API",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
@ -1148,6 +1148,44 @@ class TelegramBot extends EventEmitter {
|
|||||||
return this._request('setChatAdministratorCustomTitle', { form });
|
return this._request('setChatAdministratorCustomTitle', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to ban a channel chat in a supergroup or a channel.
|
||||||
|
* The owner of the chat will not be able to send messages and join live streams
|
||||||
|
* on behalf of the chat, unless it is unbanned first.
|
||||||
|
* The bot must be an administrator in the supergroup or channel for this to work
|
||||||
|
* and must have the appropriate administrator rights.
|
||||||
|
* Returns True on success.
|
||||||
|
*
|
||||||
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
|
* @param {Number} senderChatId Unique identifier of the target user
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
|
* @return {Boolean}
|
||||||
|
* @see https://core.telegram.org/bots/api#banchatsenderchat
|
||||||
|
*/
|
||||||
|
banChatSenderChat(chatId, senderChatId, form = {}) {
|
||||||
|
form.chat_id = chatId;
|
||||||
|
form.sender_chat_id = senderChatId;
|
||||||
|
return this._request('banChatSenderChat', { form });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
* Returns True on success.
|
||||||
|
*
|
||||||
|
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
|
||||||
|
* @param {Number} senderChatId Unique identifier of the target user
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
|
* @return {Boolean}
|
||||||
|
* @see https://core.telegram.org/bots/api#unbanchatsenderchat
|
||||||
|
*/
|
||||||
|
unbanChatSenderChat(chatId, senderChatId, form = {}) {
|
||||||
|
form.chat_id = chatId;
|
||||||
|
form.sender_chat_id = senderChatId;
|
||||||
|
return this._request('unbanChatSenderChat', { form });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this method to set default chat permissions for all members.
|
* 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
|
* The bot must be an administrator in the group or a supergroup for this to
|
||||||
@ -1507,8 +1545,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Use previously uploaded file via its file_id or specify a URL.
|
* Use previously uploaded file via its file_id or specify a URL.
|
||||||
* On success, the edited Message is returned.
|
* On success, the edited Message is returned.
|
||||||
*
|
*
|
||||||
* Note that you must provide one of chat_id, message_id, or
|
* Note that you must provide one of chat_id, message_id, or inline_message_id in your request.
|
||||||
* inline_message_id in your request.
|
|
||||||
*
|
*
|
||||||
* @param {Object} media A JSON-serialized object for a new media content of the message
|
* @param {Object} media A JSON-serialized object for a new media content of the message
|
||||||
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
|
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
|
||||||
@ -1533,7 +1570,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
const [formData] = this._formatSendData(
|
const [formData] = this._formatSendData(
|
||||||
attachName,
|
attachName,
|
||||||
media.media.replace('attach://', ''),
|
media.media.replace('attach://', ''),
|
||||||
media.fileOptions,
|
media.fileOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
if (formData) {
|
if (formData) {
|
||||||
|
@ -880,6 +880,10 @@ describe('TelegramBot', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe.skip('#banChatSenderChat', function banChatSenderChatSuite() { });
|
||||||
|
|
||||||
|
describe.skip('#unbanChatSenderChat', function banChatSenderChatSuite() { });
|
||||||
|
|
||||||
describe('#setChatPermissions ', function setChatPermissionsSuite() {
|
describe('#setChatPermissions ', function setChatPermissionsSuite() {
|
||||||
it('should set chat permissions', function test() {
|
it('should set chat permissions', function test() {
|
||||||
const ChatPermissions = {
|
const ChatPermissions = {
|
||||||
@ -904,7 +908,7 @@ describe('TelegramBot', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
it('should export the group invite link', function test() {
|
it('should export the group invite link', function test() {
|
||||||
return bot.exportChatInviteLink(GROUPID).then(resp => {
|
return bot.exportChatInviteLink(GROUPID).then(resp => {
|
||||||
assert(resp.match(/^https:\/\/t\.me\/joinchat\/.+$/i), 'is a telegram invite link');
|
assert(resp.match(/^https:\/\/t\.me\/.+$/i), 'is a telegram invite link');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -918,7 +922,7 @@ describe('TelegramBot', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
it('should create a chat invite link', function test() {
|
it('should create a chat invite link', function test() {
|
||||||
return bot.createChatInviteLink(GROUPID).then(resp => {
|
return bot.createChatInviteLink(GROUPID).then(resp => {
|
||||||
assert(resp.invite_link.match(/^https:\/\/t\.me\/joinchat\/.+$/i), 'is a telegram invite link');
|
assert(resp.invite_link.match(/^https:\/\/t\.me\/.+$/i), 'is a telegram invite link');
|
||||||
inviteLink = resp.invite_link;
|
inviteLink = resp.invite_link;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user