feat(core): Add "Sent by n8n" attribution (#7183)

Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
This commit is contained in:
Michael Kret
2023-10-03 11:18:59 +03:00
committed by GitHub
parent f0a66873b9
commit 8f9fe6269b
20 changed files with 345 additions and 57 deletions

View File

@@ -17,7 +17,7 @@ export class Telegram implements INodeType {
name: 'telegram',
icon: 'file:telegram.svg',
group: ['output'],
version: 1,
version: [1, 1.1],
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Sends data to Telegram',
defaults: {
@@ -1461,6 +1461,20 @@ export class Telegram implements INodeType {
},
default: {},
options: [
{
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
displayName: 'Append n8n Attribution',
name: 'appendAttribution',
type: 'boolean',
default: true,
description:
'Whether to include the phrase “This message was sent automatically with n8n” to the end of the message',
displayOptions: {
show: {
'/operation': ['sendMessage'],
},
},
},
{
displayName: 'Caption',
name: 'caption',
@@ -1693,6 +1707,9 @@ export class Telegram implements INodeType {
const resource = this.getNodeParameter('resource', 0);
const binaryData = this.getNodeParameter('binaryData', 0, false);
const nodeVersion = this.getNode().typeVersion;
const instanceId = await this.getInstanceId();
for (let i = 0; i < items.length; i++) {
try {
// Reset all values
@@ -1917,7 +1934,7 @@ export class Telegram implements INodeType {
body.text = this.getNodeParameter('text', i) as string;
// Add additional fields and replyMarkup
addAdditionalFields.call(this, body, i);
addAdditionalFields.call(this, body, i, nodeVersion, instanceId);
} else if (operation === 'sendMediaGroup') {
// ----------------------------------
// message:sendMediaGroup