From 1b77adac2109d885a61b30ce3346516d5352f743 Mon Sep 17 00:00:00 2001 From: rqtqp Date: Tue, 25 Feb 2025 10:16:02 +0000 Subject: [PATCH 1/3] initial add of sendVoice --- .../nodes/Telegram/Telegram.node.ts | 56 +++++++++- .../__schema__/v1.2.0/message/sendVoice.json | 104 ++++++++++++++++++ .../Telegram/tests/Workflow/apiResponses.ts | 28 +++++ .../Telegram/tests/Workflow/workflow.test.ts | 2 + 4 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index fb9b37d816..962762be10 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -244,9 +244,15 @@ export class Telegram implements INodeType { { name: 'Send Audio', value: 'sendAudio', - description: 'Send a audio file', + description: 'Send an audio file', action: 'Send an audio file', }, + { + name: 'Send Voice', + value: 'sendVoice', + description: 'Send a voice message', + action: 'Send a voice message', + }, { name: 'Send Chat Action', value: 'sendChatAction', @@ -333,6 +339,7 @@ export class Telegram implements INodeType { 'setTitle', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendChatAction', 'sendDocument', 'sendLocation', @@ -706,7 +713,7 @@ export class Telegram implements INodeType { 'Unique identifier for the target chat or username, To find your chat ID ask @get_id_bot', }, // ---------------------------------- - // message:sendAnimation/sendAudio/sendDocument/sendPhoto/sendSticker/sendVideo + // message:sendAnimation/sendAudio/sendVoice/sendDocument/sendPhoto/sendSticker/sendVideo // ---------------------------------- { @@ -720,6 +727,7 @@ export class Telegram implements INodeType { operation: [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -742,6 +750,7 @@ export class Telegram implements INodeType { operation: [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -845,6 +854,24 @@ export class Telegram implements INodeType { description: 'Audio file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, + // ---------------------------------- + // message:sendVoice + // ---------------------------------- + { + displayName: 'Voice', + name: 'file', + type: 'string', + default: '', + displayOptions: { + show: { + operation: ['sendVoice'], + resource: ['message'], + binaryData: [false], + }, + }, + description: + 'Voice message to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + }, // ---------------------------------- // message:sendChatAction @@ -870,6 +897,11 @@ export class Telegram implements INodeType { value: 'record_audio', action: 'Record audio', }, + { + name: 'Record Voice', + value: 'record_voice', + action: 'Record voice', + }, { name: 'Record Video', value: 'record_video', @@ -1159,6 +1191,7 @@ export class Telegram implements INodeType { 'sendSticker', 'sendVideo', 'sendAudio', + 'sendVoice', 'sendLocation', ], resource: ['message'], @@ -1515,6 +1548,7 @@ export class Telegram implements INodeType { 'editMessageText', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendLocation', 'sendMessage', @@ -1547,6 +1581,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -1590,7 +1625,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': ['sendAnimation', 'sendAudio', 'sendVideo'], + '/operation': ['sendAnimation', 'sendAudio', 'sendVoice', 'sendVideo'], }, }, default: 0, @@ -1606,6 +1641,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendDocument', 'sendPhoto', 'sendVideo', @@ -1656,6 +1692,7 @@ export class Telegram implements INodeType { 'editMessageText', 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendMessage', 'sendPhoto', 'sendVideo', @@ -1699,6 +1736,7 @@ export class Telegram implements INodeType { '/operation': [ 'sendAnimation', 'sendAudio', + 'sendVoice', 'sendChatAction', 'sendDocument', 'sendLocation', @@ -1989,6 +2027,18 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); + } else if (operation === 'sendVoice') { + // ---------------------------------- + // message:sendVoice + // ---------------------------------- + + endpoint = 'sendVoice'; + + body.chat_id = this.getNodeParameter('chatId', i) as string; + body.audio = this.getNodeParameter('file', i, '') as string; + + // Add additional fields and replyMarkup + addAdditionalFields.call(this, body, i); } else if (operation === 'sendChatAction') { // ---------------------------------- // message:sendChatAction diff --git a/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json new file mode 100644 index 0000000000..6942ca47ee --- /dev/null +++ b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVoice.json @@ -0,0 +1,104 @@ +{ + "type": "object", + "properties": { + "ok": { + "type": "boolean" + }, + "result": { + "type": "object", + "properties": { + "message_id": { + "type": "integer" + }, + "from": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "is_bot": { + "type": "boolean" + }, + "first_name": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": [ + "id", + "is_bot", + "first_name", + "username" + ] + }, + "chat": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "first_name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "last_name": { + "type": "string" + } + }, + "required": [ + "id", + "type" + ] + }, + "date": { + "type": "integer" + }, + "voice": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "file_name": { + "type": "string" + }, + "mime_type": { + "type": "string" + }, + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + } + }, + "required": [ + "duration", + "file_name", + "mime_type", + "file_id", + "file_unique_id", + "file_size" + ] + } + }, + "required": [ + "message_id", + "from", + "chat", + "date" + ] + } + }, + "required": [ + "ok", + "result" + ] +} diff --git a/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts b/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts index d0befde80c..c68c24d0a4 100644 --- a/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts +++ b/packages/nodes-base/nodes/Telegram/tests/Workflow/apiResponses.ts @@ -381,6 +381,34 @@ export const sendAudioResponse = { }, }, }; +export const sendVoiceResponse = { + ok: true, + result: { + message_id: 47, + from: { + id: 9876543210, + is_bot: true, + first_name: '@n8n', + username: 'n8n_test_bot', + }, + chat: { + id: 123456789, + first_name: 'Nathan', + last_name: 'W', + username: 'n8n', + type: 'private', + }, + date: 1732969291, + audio: { + duration: 3, + file_name: 'sample-3s.mp3', + mime_type: 'audio/mpeg', + file_id: 'CQACAgQAAxkDAAMuZ0sDSxCh3hW89NQa-eTpxKioqGAAAjsEAAIBCU1SGtsPA4N9TSo2BA', + file_unique_id: 'AgADOwQAAgEJTVI', + file_size: 52079, + }, + }, +}; export const getMemberResponse = { ok: true, diff --git a/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts b/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts index c752eba158..1ffa109024 100644 --- a/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts +++ b/packages/nodes-base/nodes/Telegram/tests/Workflow/workflow.test.ts @@ -11,6 +11,7 @@ import { chatAdministratorsResponse, sendAnimationMessageResponse, sendAudioResponse, + sendVoiceResponse, getMemberResponse, } from './apiResponses'; import { FAKE_CREDENTIALS_DATA } from '../../../../test/nodes/FakeCredentialsMap'; @@ -38,6 +39,7 @@ describe('Telegram', () => { mock.post('/bottestToken/getChatAdministrators').reply(200, chatAdministratorsResponse); mock.post('/bottestToken/sendAnimation').reply(200, sendAnimationMessageResponse); mock.post('/bottestToken/sendAudio').reply(200, sendAudioResponse); + mock.post('/bottestToken/sendVoice').reply(200, sendVoiceResponse); mock.post('/bottestToken/getChatMember').reply(200, getMemberResponse); }); From 81f8d0fba59d4650e21ca1e869c7b1ca10dc1be6 Mon Sep 17 00:00:00 2001 From: rqtqp Date: Sat, 1 Mar 2025 14:41:12 +0200 Subject: [PATCH 2/3] initial add sendVideoNote --- .../v1.2.0/message/sendVideoNote.json | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json diff --git a/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json new file mode 100644 index 0000000000..3bf2683bd1 --- /dev/null +++ b/packages/nodes-base/nodes/Telegram/__schema__/v1.2.0/message/sendVideoNote.json @@ -0,0 +1,140 @@ +{ + "type": "object", + "properties": { + "ok": { + "type": "boolean" + }, + "result": { + "type": "object", + "properties": { + "message_id": { + "type": "integer" + }, + "from": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "is_bot": { + "type": "boolean" + }, + "first_name": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": ["id", "is_bot", "first_name", "username"] + }, + "chat": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "type": { + "type": "string" + }, + "first_name": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": ["id", "type"] + }, + "date": { + "type": "integer" + }, + "caption": { + "type": "string" + }, + "video_note": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "file_name": { + "type": "string" + }, + "mime_type": { + "type": "string" + }, + "thumbnail": { + "type": "object", + "properties": { + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["file_id", "file_unique_id", "file_size", "width", "height"] + }, + "thumb": { + "type": "object", + "properties": { + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["file_id", "file_unique_id", "file_size", "width", "height"] + }, + "file_id": { + "type": "string" + }, + "file_unique_id": { + "type": "string" + }, + "file_size": { + "type": "integer" + } + }, + "required": [ + "duration", + "width", + "height", + "mime_type", + "file_id", + "file_unique_id", + "file_size" + ] + } + }, + "required": ["message_id", "chat", "date"] + } + }, + "required": ["ok", "result"] +} From 00bc575ee87c24005de9f1232374c8c93127d287 Mon Sep 17 00:00:00 2001 From: rqtqp Date: Sat, 1 Mar 2025 15:17:19 +0200 Subject: [PATCH 3/3] typo fix sendVideoNote --- .../nodes/Telegram/Telegram.node.ts | 67 ++++++++++++++++--- pnpm-lock.yaml | 18 ++--- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index 962762be10..ef8973cb8b 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -307,6 +307,12 @@ export class Telegram implements INodeType { description: 'Send a video', action: 'Send a video', }, + { + name: 'Send Video Note', + value: 'sendVideoNote', + description: 'Send a video note', + action: 'Send a video note', + }, { name: 'Unpin Chat Message', value: 'unpinChatMessage', @@ -348,6 +354,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', 'unpinChatMessage', ], resource: ['chat', 'message'], @@ -713,7 +720,7 @@ export class Telegram implements INodeType { 'Unique identifier for the target chat or username, To find your chat ID ask @get_id_bot', }, // ---------------------------------- - // message:sendAnimation/sendAudio/sendVoice/sendDocument/sendPhoto/sendSticker/sendVideo + // message:sendAnimation/sendAudio/sendVoice/sendDocument/sendPhoto/sendSticker/sendVideo/sendVideoNote // ---------------------------------- { @@ -731,6 +738,7 @@ export class Telegram implements INodeType { 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendSticker', ], resource: ['message'], @@ -754,6 +762,7 @@ export class Telegram implements INodeType { 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendSticker', ], resource: ['message'], @@ -871,7 +880,7 @@ export class Telegram implements INodeType { }, description: 'Voice message to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', - }, + }, // ---------------------------------- // message:sendChatAction @@ -901,7 +910,7 @@ export class Telegram implements INodeType { name: 'Record Voice', value: 'record_voice', action: 'Record voice', - }, + }, { name: 'Record Video', value: 'record_video', @@ -1173,11 +1182,27 @@ export class Telegram implements INodeType { description: 'Video file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, - // ---------------------------------- - // message:editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo + // message:sendVideoNote + // ---------------------------------- + { + displayName: 'VideoNote', + name: 'file', + type: 'string', + default: '', + displayOptions: { + show: { + operation: ['sendVideoNote'], + resource: ['message'], + binaryData: [false], + }, + }, + description: + 'VideoNote file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + }, + // ---------------------------------- + // message:editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo/SendVideoNote // ---------------------------------- - { displayName: 'Reply Markup', name: 'replyMarkup', @@ -1190,6 +1215,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', 'sendAudio', 'sendVoice', 'sendLocation', @@ -1223,7 +1249,6 @@ export class Telegram implements INodeType { default: 'none', description: 'Additional interface options', }, - { displayName: 'Force Reply', name: 'forceReply', @@ -1254,7 +1279,6 @@ export class Telegram implements INodeType { }, ], }, - { displayName: 'Inline Keyboard', name: 'inlineKeyboard', @@ -1556,6 +1580,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', ], resource: ['message'], }, @@ -1585,6 +1610,7 @@ export class Telegram implements INodeType { 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', ], }, }, @@ -1645,6 +1671,7 @@ export class Telegram implements INodeType { 'sendDocument', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendSticker', ], '/resource': ['message'], @@ -1696,6 +1723,7 @@ export class Telegram implements INodeType { 'sendMessage', 'sendPhoto', 'sendVideo', + 'sendVideoNote', 'sendDocument', ], }, @@ -1745,6 +1773,7 @@ export class Telegram implements INodeType { 'sendPhoto', 'sendSticker', 'sendVideo', + 'sendVideoNote', ], }, }, @@ -1769,7 +1798,13 @@ export class Telegram implements INodeType { type: 'string', displayOptions: { show: { - '/operation': ['sendAnimation', 'sendAudio', 'sendDocument', 'sendVideo'], + '/operation': [ + 'sendAnimation', + 'sendAudio', + 'sendDocument', + 'sendVideo', + 'sendVideoNote', + ], }, }, default: '', @@ -2038,7 +2073,7 @@ export class Telegram implements INodeType { body.audio = this.getNodeParameter('file', i, '') as string; // Add additional fields and replyMarkup - addAdditionalFields.call(this, body, i); + addAdditionalFields.call(this, body, i); } else if (operation === 'sendChatAction') { // ---------------------------------- // message:sendChatAction @@ -2140,6 +2175,18 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.video = this.getNodeParameter('file', i, '') as string; + // Add additional fields and replyMarkup + addAdditionalFields.call(this, body, i); + } else if (operation === 'sendVideoNote') { + // ---------------------------------- + // message:sendVideoNote + // ---------------------------------- + + endpoint = 'sendVideoNote'; + + body.chat_id = this.getNodeParameter('chatId', i) as string; + body.video = this.getNodeParameter('file', i, '') as string; + // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d711644562..edc72f250f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7034,6 +7034,7 @@ packages: bson@6.10.0: resolution: {integrity: sha512-ROchNosXMJD2cbQGm84KoP7vOGPO6/bOAW0veMMbzhXLqoZptcaYRVLitwvuhwhjjpU1qP4YZRWLhgETdgqUQw==} engines: {node: '>=16.20.1'} + deprecated: a critical bug affecting only useBigInt64=true deserialization usage is fixed in bson@6.10.3 buffer-crc32@0.2.13: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} @@ -7874,10 +7875,6 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - detect-libc@2.0.1: - resolution: {integrity: sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==} - engines: {node: '>=8'} - detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -8890,6 +8887,7 @@ packages: gm@1.25.0: resolution: {integrity: sha512-4kKdWXTtgQ4biIo7hZA396HT062nDVVHPjQcurNZ3o/voYN+o5FUC5kOwuORbpExp3XbTJ3SU7iRipiIhQtovw==} engines: {node: '>=14'} + deprecated: The gm module has been sunset. Please migrate to an alternative. https://github.com/aheckmann/gm?tab=readme-ov-file#2025-02-24-this-project-is-not-maintained google-auth-library@8.9.0: resolution: {integrity: sha512-f7aQCJODJFmYWN6PeNKzgvy9LI2tYmXnzpNDHEjG5sDNPgGb2FXQyTBnXeSH+PAtpKESFD+LmHw3Ox3mN7e1Fg==} @@ -8912,9 +8910,6 @@ packages: gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} - graceful-fs@4.2.10: - resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} - graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} @@ -21131,8 +21126,6 @@ snapshots: destroy@1.2.0: {} - detect-libc@2.0.1: {} - detect-libc@2.0.3: {} detect-newline@3.1.0: {} @@ -22537,9 +22530,6 @@ snapshots: dependencies: get-intrinsic: 1.2.4 - graceful-fs@4.2.10: - optional: true - graceful-fs@4.2.11: {} graphemer@1.4.0: {} @@ -24888,7 +24878,7 @@ snapshots: dependencies: env-paths: 2.2.1 glob: 7.2.3 - graceful-fs: 4.2.10 + graceful-fs: 4.2.11 make-fetch-happen: 9.1.0 nopt: 5.0.0 npmlog: 6.0.2 @@ -25573,7 +25563,7 @@ snapshots: prebuild-install@7.1.1: dependencies: - detect-libc: 2.0.1 + detect-libc: 2.0.3 expand-template: 2.0.3 github-from-package: 0.0.0 minimist: 1.2.8