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

feat(Telegram Node): Add editMessageCaption action #8862

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
72 changes: 58 additions & 14 deletions packages/editor-ui/src/utils/testData/nodeTypeTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,12 @@ export const nodeTypeTelegramV1 = {
description: 'Delete a chat message',
action: 'Delete a chat message',
},
{
name: 'Edit Message Caption',
value: 'editMessageCaption',
description: 'Edit a caption of message',
action: 'Edit a caption of test message',
},
{
name: 'Edit Message Text',
value: 'editMessageText',
Expand Down Expand Up @@ -2231,7 +2237,9 @@ export const nodeTypeTelegramV1 = {
displayName: 'Message Type',
name: 'messageType',
type: 'options',
displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
displayOptions: {
show: { operation: ['editMessageText', 'editMessageCaption'], resource: ['message'] },
},
options: [
{ name: 'Inline Message', value: 'inlineMessage' },
{ name: 'Message', value: 'message' },
Expand All @@ -2245,7 +2253,11 @@ export const nodeTypeTelegramV1 = {
type: 'string',
default: '',
displayOptions: {
show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
show: {
messageType: ['message'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
required: true,
description:
Expand Down Expand Up @@ -2301,7 +2313,11 @@ export const nodeTypeTelegramV1 = {
type: 'string',
default: '',
displayOptions: {
show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
show: {
messageType: ['message'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
required: true,
description: 'Unique identifier of the message to edit',
Expand All @@ -2314,7 +2330,7 @@ export const nodeTypeTelegramV1 = {
displayOptions: {
show: {
messageType: ['inlineMessage'],
operation: ['editMessageText'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
Expand All @@ -2324,7 +2340,9 @@ export const nodeTypeTelegramV1 = {
{
displayName: 'Reply Markup',
name: 'replyMarkup',
displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
displayOptions: {
show: { operation: ['editMessageText', 'editMessageCaption'], resource: ['message'] },
},
type: 'options',
options: [
{ name: 'None', value: 'none' },
Expand Down Expand Up @@ -2520,6 +2538,7 @@ export const nodeTypeTelegramV1 = {
displayOptions: {
show: {
operation: [
'editMessageCaption',
'sendAnimation',
'sendDocument',
'sendMessage',
Expand Down Expand Up @@ -2788,6 +2807,7 @@ export const nodeTypeTelegramV1 = {
displayOptions: {
show: {
operation: [
'editMessageCaption',
'editMessageText',
'sendAnimation',
'sendAudio',
Expand Down Expand Up @@ -2820,6 +2840,7 @@ export const nodeTypeTelegramV1 = {
displayOptions: {
show: {
'/operation': [
'editMessageCaption',
'sendAnimation',
'sendAudio',
'sendDocument',
Expand All @@ -2836,7 +2857,7 @@ export const nodeTypeTelegramV1 = {
name: 'disable_notification',
type: 'boolean',
default: false,
displayOptions: { hide: { '/operation': ['editMessageText'] } },
displayOptions: { hide: { '/operation': ['editMessageText', 'editMessageCaption'] } },
description:
'Whether to send the message silently. Users will receive a notification with no sound.',
},
Expand Down Expand Up @@ -2899,6 +2920,7 @@ export const nodeTypeTelegramV1 = {
displayOptions: {
show: {
'/operation': [
'editMessageCaption',
'editMessageText',
'sendAnimation',
'sendAudio',
Expand All @@ -2924,7 +2946,7 @@ export const nodeTypeTelegramV1 = {
displayName: 'Reply To Message ID',
name: 'reply_to_message_id',
type: 'number',
displayOptions: { hide: { '/operation': ['editMessageText'] } },
displayOptions: { hide: { '/operation': ['editMessageText', 'editMessageCaption'] } },
default: 0,
description: 'If the message is a reply, ID of the original message',
},
Expand Down Expand Up @@ -3109,6 +3131,12 @@ export const nodeTypeTelegramV1_1 = {
description: 'Delete a chat message',
action: 'Delete a chat message',
},
{
name: 'Edit Message Caption',
value: 'editMessageCaption',
description: 'Edit a caption of message',
action: 'Edit a caption of test message',
},
{
name: 'Edit Message Text',
value: 'editMessageText',
Expand Down Expand Up @@ -3422,7 +3450,9 @@ export const nodeTypeTelegramV1_1 = {
displayName: 'Message Type',
name: 'messageType',
type: 'options',
displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
displayOptions: {
show: { operation: ['editMessageText', 'editMessageCaption'], resource: ['message'] },
},
options: [
{ name: 'Inline Message', value: 'inlineMessage' },
{ name: 'Message', value: 'message' },
Expand All @@ -3436,7 +3466,11 @@ export const nodeTypeTelegramV1_1 = {
type: 'string',
default: '',
displayOptions: {
show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
show: {
messageType: ['message'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
required: true,
description:
Expand Down Expand Up @@ -3492,7 +3526,11 @@ export const nodeTypeTelegramV1_1 = {
type: 'string',
default: '',
displayOptions: {
show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
show: {
messageType: ['message'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
required: true,
description: 'Unique identifier of the message to edit',
Expand All @@ -3505,7 +3543,7 @@ export const nodeTypeTelegramV1_1 = {
displayOptions: {
show: {
messageType: ['inlineMessage'],
operation: ['editMessageText'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
Expand All @@ -3515,7 +3553,9 @@ export const nodeTypeTelegramV1_1 = {
{
displayName: 'Reply Markup',
name: 'replyMarkup',
displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
displayOptions: {
show: { operation: ['editMessageText', 'editMessageCaption'], resource: ['message'] },
},
type: 'options',
options: [
{ name: 'None', value: 'none' },
Expand Down Expand Up @@ -3711,6 +3751,7 @@ export const nodeTypeTelegramV1_1 = {
displayOptions: {
show: {
operation: [
'editMessageCaption',
'sendAnimation',
'sendDocument',
'sendMessage',
Expand Down Expand Up @@ -3979,6 +4020,7 @@ export const nodeTypeTelegramV1_1 = {
displayOptions: {
show: {
operation: [
'editMessageCaption',
'editMessageText',
'sendAnimation',
'sendAudio',
Expand Down Expand Up @@ -4011,6 +4053,7 @@ export const nodeTypeTelegramV1_1 = {
displayOptions: {
show: {
'/operation': [
'editMessageCaption',
'sendAnimation',
'sendAudio',
'sendDocument',
Expand All @@ -4027,7 +4070,7 @@ export const nodeTypeTelegramV1_1 = {
name: 'disable_notification',
type: 'boolean',
default: false,
displayOptions: { hide: { '/operation': ['editMessageText'] } },
displayOptions: { hide: { '/operation': ['editMessageText', 'editMessageCaption'] } },
description:
'Whether to send the message silently. Users will receive a notification with no sound.',
},
Expand Down Expand Up @@ -4090,6 +4133,7 @@ export const nodeTypeTelegramV1_1 = {
displayOptions: {
show: {
'/operation': [
'editMessageCaption',
'editMessageText',
'sendAnimation',
'sendAudio',
Expand All @@ -4115,7 +4159,7 @@ export const nodeTypeTelegramV1_1 = {
displayName: 'Reply To Message ID',
name: 'reply_to_message_id',
type: 'number',
displayOptions: { hide: { '/operation': ['editMessageText'] } },
displayOptions: { hide: { '/operation': ['editMessageText', 'editMessageCaption'] } },
default: 0,
description: 'If the message is a reply, ID of the original message',
},
Expand Down
46 changes: 37 additions & 9 deletions packages/nodes-base/nodes/Telegram/Telegram.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ export class Telegram implements INodeType {
description: 'Delete a chat message',
action: 'Delete a chat message',
},
{
name: 'Edit Message Caption',
value: 'editMessageCaption',
description: 'Edit the caption of a message',
action: 'Edit the caption of a message',
},
{
name: 'Edit Message Text',
value: 'editMessageText',
Expand Down Expand Up @@ -641,7 +647,7 @@ export class Telegram implements INodeType {
// ----------------------------------

// ----------------------------------
// message:editMessageText
// message:editMessageText/editMessageCaption
// ----------------------------------

{
Expand All @@ -650,7 +656,7 @@ export class Telegram implements INodeType {
type: 'options',
displayOptions: {
show: {
operation: ['editMessageText'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
Expand All @@ -676,7 +682,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
messageType: ['message'],
operation: ['editMessageText'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
Expand Down Expand Up @@ -741,7 +747,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
messageType: ['message'],
operation: ['editMessageText'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
Expand All @@ -756,7 +762,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
messageType: ['inlineMessage'],
operation: ['editMessageText'],
operation: ['editMessageText', 'editMessageCaption'],
resource: ['message'],
},
},
Expand Down Expand Up @@ -1122,7 +1128,7 @@ export class Telegram implements INodeType {
},

// ----------------------------------
// message:editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo
// message:editMessageCaption/editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo
// ----------------------------------

{
Expand All @@ -1131,6 +1137,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
operation: [
'editMessageCaption',
'sendAnimation',
'sendDocument',
'sendMessage',
Expand Down Expand Up @@ -1451,6 +1458,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
operation: [
'editMessageCaption',
'editMessageText',
'sendAnimation',
'sendAudio',
Expand Down Expand Up @@ -1488,6 +1496,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
'/operation': [
'editMessageCaption',
'sendAnimation',
'sendAudio',
'sendDocument',
Expand All @@ -1506,7 +1515,7 @@ export class Telegram implements INodeType {
default: false,
displayOptions: {
hide: {
'/operation': ['editMessageText'],
'/operation': ['editMessageText', 'editMessageCaption'],
},
},
description:
Expand Down Expand Up @@ -1596,6 +1605,7 @@ export class Telegram implements INodeType {
displayOptions: {
show: {
'/operation': [
'editMessageCaption',
'editMessageText',
'sendAnimation',
'sendAudio',
Expand Down Expand Up @@ -1627,7 +1637,7 @@ export class Telegram implements INodeType {
type: 'number',
displayOptions: {
hide: {
'/operation': ['editMessageText'],
'/operation': ['editMessageText', 'editMessageCaption'],
},
},
default: 0,
Expand Down Expand Up @@ -1823,7 +1833,25 @@ export class Telegram implements INodeType {
body.file_id = this.getNodeParameter('fileId', i) as string;
}
} else if (resource === 'message') {
if (operation === 'editMessageText') {
if (operation === 'editMessageCaption') {
// ----------------------------------
// message:editMessageCaption
// ----------------------------------

endpoint = 'editMessageCaption';

const messageType = this.getNodeParameter('messageType', i) as string;

if (messageType === 'inlineMessage') {
body.inline_message_id = this.getNodeParameter('inlineMessageId', i) as string;
} else {
body.chat_id = this.getNodeParameter('chatId', i) as string;
body.message_id = this.getNodeParameter('messageId', i) as string;
}

// Add additional fields and replyMarkup
addAdditionalFields.call(this, body, i);
} else if (operation === 'editMessageText') {
// ----------------------------------
// message:editMessageText
// ----------------------------------
Expand Down