Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method copyMessage, parameter protect_content and MarkdownV2 #678

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('connect', () => {
},
},
});
LineClient.connect({
// eslint-disable-next-line no-new
new LineClient({
accessToken: ACCESS_TOKEN,
channelSecret: CHANNEL_SECRET,
});
Expand All @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion packages/messaging-api-line/src/__tests__/LineNotify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/messaging-api-line/src/__tests__/LinePay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -65,7 +67,8 @@ describe('connect', () => {
},
},
});
MessengerClient.connect({
// eslint-disable-next-line no-new
new MessengerClient({
accessToken: ACCESS_TOKEN,
origin: 'https://mydummytestserver.com',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand All @@ -42,7 +43,8 @@ describe('connect', () => {
},
},
});
SlackOAuthClient.connect({
// eslint-disable-next-line no-new
new SlackOAuthClient({
accessToken: TOKEN,
origin: 'https://mydummytestserver.com',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 34 additions & 0 deletions packages/messaging-api-telegram/src/TelegramClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TelegramTypes.Message> {
return this.request('/copyMessage', {
chatId,
fromChatId,
messageId,
...options,
});
}

/**
* Use this method to send photos.
*
Expand Down
Loading