From 574827816d861f5ddaaea900c34ec66b137e24fe Mon Sep 17 00:00:00 2001 From: Cojad Date: Sun, 20 Mar 2022 13:09:32 +0800 Subject: [PATCH 1/3] add method copyMessage for telegram Bot API 5.0, add parameter protect_content for telegram Bot API 5.6. --- .../src/TelegramClient.ts | 34 ++++ .../src/TelegramTypes.ts | 186 ++++++++++++++++++ 2 files changed, 220 insertions(+) diff --git a/packages/messaging-api-telegram/src/TelegramClient.ts b/packages/messaging-api-telegram/src/TelegramClient.ts index 11537c62..5b87f9eb 100644 --- a/packages/messaging-api-telegram/src/TelegramClient.ts +++ b/packages/messaging-api-telegram/src/TelegramClient.ts @@ -322,6 +322,40 @@ export default class TelegramClient { }); } + /** + * Use this method to forward messages of any kind. + * + * @param chatId - Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) + * @param fromChatId - Unique identifier for the chat where the original message was sent (or channel username in the format `@channelusername`) + * @param messageId - Message identifier in the chat specified in fromChatId + * @param options - Options for other optional parameters. + * @returns On success, the sent Message is returned. + * + * @see https://core.telegram.org/bots/api#copymessage + * + * @example + * + * ```js + * await client.copyMessage(CHAT_ID, USER_ID, MESSAGE_ID, { + * disableNotification: true, + * protect_content: true, + * }); + * ``` + */ + copyMessage( + chatId: string | number, + fromChatId: string | number, + messageId: number, + options?: TelegramTypes.CopyMessageOption + ): Promise { + return this.request('/copyMessage', { + chatId, + fromChatId, + messageId, + ...options, + }); + } + /** * Use this method to send photos. * diff --git a/packages/messaging-api-telegram/src/TelegramTypes.ts b/packages/messaging-api-telegram/src/TelegramTypes.ts index 2ca554cf..19f72302 100644 --- a/packages/messaging-api-telegram/src/TelegramTypes.ts +++ b/packages/messaging-api-telegram/src/TelegramTypes.ts @@ -1468,6 +1468,7 @@ export type SendMessageOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1486,6 +1487,13 @@ export type SendMessageOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1509,6 +1517,7 @@ export type SendMessageOption = { }; export enum ParseMode { + MarkdownV2 = 'MarkdownV2', Markdown = 'Markdown', HTML = 'HTML', } @@ -1518,6 +1527,70 @@ export type ForwardMessageOption = { * Sends the message silently. Users will receive a notification with no sound. */ disableNotification?: boolean; + + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; +}; + +export type CopyMessageOption = { + /** + * New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept + */ + caption?: string; + + /** + * Mode for parsing entities in the new caption. See formatting options for more details. + * + * - https://core.telegram.org/bots/api#markdownv2-style + * - https://core.telegram.org/bots/api#markdown-style + * - https://core.telegram.org/bots/api#html-style + * - https://core.telegram.org/bots/api#formatting-options + */ + parseMode?: ParseMode; + + /** + * Sends the message silently. Users will receive a notification with no sound. + * + * - https://telegram.org/blog/channels-2-0#silent-messages + */ + disableNotification?: boolean; + + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + + /** + * If the message is a reply, ID of the original message + */ + replyToMessageId?: number; + + /** + * Pass True, if the message should be sent even if the specified replied-to message is not found + */ + allow_sending_without_reply?: boolean; + + /** + * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * + * - https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating + * - https://core.telegram.org/bots#keyboards + * - https://core.telegram.org/bots/api#inlinekeyboardmarkup + * - https://core.telegram.org/bots/api#replykeyboardmarkup + * - https://core.telegram.org/bots/api#replykeyboardremove + * - https://core.telegram.org/bots/api#forcereply + */ + replyMarkup?: + | InlineKeyboardMarkup + | ReplyKeyboardMarkup + | ReplyKeyboardRemove + | ForceReply; }; export type SendPhotoOption = { @@ -1529,6 +1602,7 @@ export type SendPhotoOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1542,6 +1616,13 @@ export type SendPhotoOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1573,6 +1654,7 @@ export type SendAudioOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1606,6 +1688,13 @@ export type SendAudioOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1642,6 +1731,7 @@ export type SendDocumentOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1655,6 +1745,13 @@ export type SendDocumentOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1706,6 +1803,7 @@ export type SendVideoOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1724,6 +1822,13 @@ export type SendVideoOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1775,6 +1880,7 @@ export type SendAnimationOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1788,6 +1894,13 @@ export type SendAnimationOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1824,6 +1937,7 @@ export type SendVoiceOption = { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -1837,6 +1951,13 @@ export type SendVoiceOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1882,6 +2003,13 @@ export type SendVideoNoteOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1912,6 +2040,13 @@ export type SendMediaGroupOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -1933,6 +2068,13 @@ export type SendLocationOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -2012,6 +2154,13 @@ export type SendVenueOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -2066,6 +2215,13 @@ export type SendContactOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -2141,6 +2297,13 @@ export type SendPollOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -2242,6 +2405,7 @@ export type EditMessageTextOption = EditOption & { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -2266,6 +2430,7 @@ export type EditMessageCaptionOption = EditOption & { /** * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. * + * - https://core.telegram.org/bots/api#markdownv2-style * - https://core.telegram.org/bots/api#markdown-style * - https://core.telegram.org/bots/api#html-style * - https://core.telegram.org/bots/api#formatting-options @@ -2311,6 +2476,13 @@ export type SendStickerOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -2432,6 +2604,13 @@ export type SendInvoiceOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ @@ -2499,6 +2678,13 @@ export type SendGameOption = { */ disableNotification?: boolean; + /** + * Protects the contents of the sent message from forwarding and saving + * + * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels + */ + protect_content?: boolean; + /** * If the message is a reply, ID of the original message */ From d6024e235579ca7d537b0729da7fee0432ba98ac Mon Sep 17 00:00:00 2001 From: Cojad Date: Sun, 20 Mar 2022 13:54:24 +0800 Subject: [PATCH 2/3] use camelcase instead of snakecase style, --- .../src/TelegramTypes.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/messaging-api-telegram/src/TelegramTypes.ts b/packages/messaging-api-telegram/src/TelegramTypes.ts index 19f72302..d827d066 100644 --- a/packages/messaging-api-telegram/src/TelegramTypes.ts +++ b/packages/messaging-api-telegram/src/TelegramTypes.ts @@ -1492,7 +1492,7 @@ export type SendMessageOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1533,7 +1533,7 @@ export type ForwardMessageOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; }; export type CopyMessageOption = { @@ -1564,7 +1564,7 @@ export type CopyMessageOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1621,7 +1621,7 @@ export type SendPhotoOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1693,7 +1693,7 @@ export type SendAudioOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1750,7 +1750,7 @@ export type SendDocumentOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1827,7 +1827,7 @@ export type SendVideoOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1899,7 +1899,7 @@ export type SendAnimationOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -1956,7 +1956,7 @@ export type SendVoiceOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2008,7 +2008,7 @@ export type SendVideoNoteOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2045,7 +2045,7 @@ export type SendMediaGroupOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2073,7 +2073,7 @@ export type SendLocationOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2159,7 +2159,7 @@ export type SendVenueOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2220,7 +2220,7 @@ export type SendContactOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2302,7 +2302,7 @@ export type SendPollOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2481,7 +2481,7 @@ export type SendStickerOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2609,7 +2609,7 @@ export type SendInvoiceOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message @@ -2683,7 +2683,7 @@ export type SendGameOption = { * * - https://telegram.org/blog/protected-content-delete-by-date-and-more#protected-content-in-groups-and-channels */ - protect_content?: boolean; + protectContent?: boolean; /** * If the message is a reply, ID of the original message From c7944dad203a050a76800ce11e2a45229d10bc05 Mon Sep 17 00:00:00 2001 From: Cojad Date: Sun, 20 Mar 2022 21:25:53 +0800 Subject: [PATCH 3/3] update deprecated xxx.connect() with new xxx() - no more deprecated connect method in test files --- .../src/__tests__/LineClient-constructor.spec.ts | 6 ++++-- .../messaging-api-line/src/__tests__/LineNotify.spec.ts | 3 ++- .../messaging-api-line/src/__tests__/LinePay.spec.ts | 3 ++- .../src/__tests__/MessengerClient-constructor.spec.ts | 9 ++++++--- .../src/__tests__/SlackOAuthClient-constructor.spec.ts | 6 ++++-- .../src/__tests__/SlackWebhookClient-constructor.spec.ts | 3 ++- .../src/__tests__/TelegramClient-constructor.spec.ts | 6 ++++-- .../src/__tests__/TelegramClient.spec.ts | 4 ++++ .../src/__tests__/ViberClient-constructor.spec.ts | 6 ++++-- .../src/__tests__/WechatClient-constructor.spec.ts | 6 ++++-- 10 files changed, 36 insertions(+), 16 deletions(-) diff --git a/packages/messaging-api-line/src/__tests__/LineClient-constructor.spec.ts b/packages/messaging-api-line/src/__tests__/LineClient-constructor.spec.ts index 5bdbcf61..96052901 100644 --- a/packages/messaging-api-line/src/__tests__/LineClient-constructor.spec.ts +++ b/packages/messaging-api-line/src/__tests__/LineClient-constructor.spec.ts @@ -26,7 +26,8 @@ describe('connect', () => { }, }, }); - LineClient.connect({ + // eslint-disable-next-line no-new + new LineClient({ accessToken: ACCESS_TOKEN, channelSecret: CHANNEL_SECRET, }); @@ -49,7 +50,8 @@ describe('connect', () => { }, }, }); - LineClient.connect({ + // eslint-disable-next-line no-new + new LineClient({ accessToken: ACCESS_TOKEN, channelSecret: CHANNEL_SECRET, origin: 'https://mydummytestserver.com', diff --git a/packages/messaging-api-line/src/__tests__/LineNotify.spec.ts b/packages/messaging-api-line/src/__tests__/LineNotify.spec.ts index e04cf14a..ad4de2b8 100644 --- a/packages/messaging-api-line/src/__tests__/LineNotify.spec.ts +++ b/packages/messaging-api-line/src/__tests__/LineNotify.spec.ts @@ -37,7 +37,8 @@ describe('connect', () => { it('create axios with LINE Notify API', () => { axios.create = jest.fn(); - LineNotify.connect({ + // eslint-disable-next-line no-new + new LineNotify({ clientId: CLIENT_ID, clientSecret: CLIENT_SECRET, redirectUri: REDIRECT_URI, diff --git a/packages/messaging-api-line/src/__tests__/LinePay.spec.ts b/packages/messaging-api-line/src/__tests__/LinePay.spec.ts index 04402871..d0c28970 100644 --- a/packages/messaging-api-line/src/__tests__/LinePay.spec.ts +++ b/packages/messaging-api-line/src/__tests__/LinePay.spec.ts @@ -31,7 +31,8 @@ describe('connect', () => { it('create axios with LINE PAY API', () => { axios.create = jest.fn(); - LinePay.connect({ + // eslint-disable-next-line no-new + new LinePay({ channelId: CHANNEL_ID, channelSecret: CHANNEL_SECRET, }); diff --git a/packages/messaging-api-messenger/src/__tests__/MessengerClient-constructor.spec.ts b/packages/messaging-api-messenger/src/__tests__/MessengerClient-constructor.spec.ts index 110850ac..9fa8c609 100644 --- a/packages/messaging-api-messenger/src/__tests__/MessengerClient-constructor.spec.ts +++ b/packages/messaging-api-messenger/src/__tests__/MessengerClient-constructor.spec.ts @@ -26,7 +26,8 @@ describe('connect', () => { }, }, }); - MessengerClient.connect({ accessToken: ACCESS_TOKEN }); + // eslint-disable-next-line no-new + new MessengerClient({ accessToken: ACCESS_TOKEN }); expect(axios.create).toBeCalledWith( expect.objectContaining({ @@ -46,7 +47,8 @@ describe('connect', () => { }, }, }); - MessengerClient.connect({ accessToken: ACCESS_TOKEN, version: '2.6' }); + // eslint-disable-next-line no-new + new MessengerClient({ accessToken: ACCESS_TOKEN, version: '2.6' }); expect(axios.create).toBeCalledWith( expect.objectContaining({ @@ -65,7 +67,8 @@ describe('connect', () => { }, }, }); - MessengerClient.connect({ + // eslint-disable-next-line no-new + new MessengerClient({ accessToken: ACCESS_TOKEN, origin: 'https://mydummytestserver.com', }); diff --git a/packages/messaging-api-slack/src/__tests__/SlackOAuthClient-constructor.spec.ts b/packages/messaging-api-slack/src/__tests__/SlackOAuthClient-constructor.spec.ts index 5595b4c9..f6aa7390 100644 --- a/packages/messaging-api-slack/src/__tests__/SlackOAuthClient-constructor.spec.ts +++ b/packages/messaging-api-slack/src/__tests__/SlackOAuthClient-constructor.spec.ts @@ -25,7 +25,8 @@ describe('connect', () => { }, }, }); - SlackOAuthClient.connect({ accessToken: TOKEN }); + // eslint-disable-next-line no-new + new SlackOAuthClient({ accessToken: TOKEN }); expect(axios.create).toBeCalledWith({ baseURL: 'https://slack.com/api/', @@ -42,7 +43,8 @@ describe('connect', () => { }, }, }); - SlackOAuthClient.connect({ + // eslint-disable-next-line no-new + new SlackOAuthClient({ accessToken: TOKEN, origin: 'https://mydummytestserver.com', }); diff --git a/packages/messaging-api-slack/src/__tests__/SlackWebhookClient-constructor.spec.ts b/packages/messaging-api-slack/src/__tests__/SlackWebhookClient-constructor.spec.ts index c9456a00..d3bc21e9 100644 --- a/packages/messaging-api-slack/src/__tests__/SlackWebhookClient-constructor.spec.ts +++ b/packages/messaging-api-slack/src/__tests__/SlackWebhookClient-constructor.spec.ts @@ -25,7 +25,8 @@ describe('connect', () => { }, }, }); - SlackWebhookClient.connect({ url: URL }); + // eslint-disable-next-line no-new + new SlackWebhookClient({ url: URL }); expect(axios.create).toBeCalledWith({ baseURL: diff --git a/packages/messaging-api-telegram/src/__tests__/TelegramClient-constructor.spec.ts b/packages/messaging-api-telegram/src/__tests__/TelegramClient-constructor.spec.ts index 06f2a172..70694ce6 100644 --- a/packages/messaging-api-telegram/src/__tests__/TelegramClient-constructor.spec.ts +++ b/packages/messaging-api-telegram/src/__tests__/TelegramClient-constructor.spec.ts @@ -33,7 +33,8 @@ describe('connect', () => { }, }, }); - TelegramClient.connect({ accessToken: ACCESS_TOKEN }); + // eslint-disable-next-line no-new + new TelegramClient({ accessToken: ACCESS_TOKEN }); expect(axios.create).toBeCalledWith({ baseURL: @@ -53,7 +54,8 @@ describe('connect', () => { }, }, }); - TelegramClient.connect({ + // eslint-disable-next-line no-new + new TelegramClient({ accessToken: ACCESS_TOKEN, origin: 'https://mydummytestserver.com', }); diff --git a/packages/messaging-api-telegram/src/__tests__/TelegramClient.spec.ts b/packages/messaging-api-telegram/src/__tests__/TelegramClient.spec.ts index ebe85ba8..47d864e3 100644 --- a/packages/messaging-api-telegram/src/__tests__/TelegramClient.spec.ts +++ b/packages/messaging-api-telegram/src/__tests__/TelegramClient.spec.ts @@ -814,12 +814,14 @@ describe('other api', () => { from_chat_id: 313534466, message_id: 203, disable_notification: true, + protect_content: true, }) .reply(200, reply); const res = await client.forwardMessage(427770117, 313534466, 203, { // @ts-expect-error disable_notification: true, + protect_content: true, }); expect(res).toEqual(result); @@ -833,11 +835,13 @@ describe('other api', () => { from_chat_id: 313534466, message_id: 203, disable_notification: true, + protect_content: true, }) .reply(200, reply); const res = await client.forwardMessage(427770117, 313534466, 203, { disableNotification: true, + protectContent: true, }); expect(res).toEqual(result); diff --git a/packages/messaging-api-viber/src/__tests__/ViberClient-constructor.spec.ts b/packages/messaging-api-viber/src/__tests__/ViberClient-constructor.spec.ts index 8852ec91..ac89af7d 100644 --- a/packages/messaging-api-viber/src/__tests__/ViberClient-constructor.spec.ts +++ b/packages/messaging-api-viber/src/__tests__/ViberClient-constructor.spec.ts @@ -30,7 +30,8 @@ describe('connect', () => { }, }, }); - ViberClient.connect({ accessToken: AUTH_TOKEN, sender: SENDER }); + // eslint-disable-next-line no-new + new ViberClient({ accessToken: AUTH_TOKEN, sender: SENDER }); expect(axios.create).toBeCalledWith({ baseURL: 'https://chatapi.viber.com/pa/', @@ -50,7 +51,8 @@ describe('connect', () => { }, }, }); - ViberClient.connect({ + // eslint-disable-next-line no-new + new ViberClient({ accessToken: AUTH_TOKEN, sender: SENDER, origin: 'https://mydummytestserver.com', diff --git a/packages/messaging-api-wechat/src/__tests__/WechatClient-constructor.spec.ts b/packages/messaging-api-wechat/src/__tests__/WechatClient-constructor.spec.ts index cbc0e7b6..326c442e 100644 --- a/packages/messaging-api-wechat/src/__tests__/WechatClient-constructor.spec.ts +++ b/packages/messaging-api-wechat/src/__tests__/WechatClient-constructor.spec.ts @@ -26,7 +26,8 @@ describe('connect', () => { }, }, }); - WechatClient.connect({ appId: APP_ID, appSecret: APP_SECRET }); + // eslint-disable-next-line no-new + new WechatClient({ appId: APP_ID, appSecret: APP_SECRET }); expect(axios.create).toBeCalledWith({ baseURL: 'https://api.weixin.qq.com/cgi-bin/', @@ -45,7 +46,8 @@ describe('connect', () => { }, }, }); - WechatClient.connect({ + // eslint-disable-next-line no-new + new WechatClient({ appId: APP_ID, appSecret: APP_SECRET, origin: 'https://mydummytestserver.com',