mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
✨ Add message pinning and unpinning to Telegram (#1398)
* Implement chat message pinning and unpinning
* ⚡ Add svg logo
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
parent
eb2f14d06d
commit
049bf6bee8
|
@ -19,7 +19,7 @@ export class Telegram implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'Telegram',
|
displayName: 'Telegram',
|
||||||
name: 'telegram',
|
name: 'telegram',
|
||||||
icon: 'file:telegram.png',
|
icon: 'file:telegram.svg',
|
||||||
group: ['output'],
|
group: ['output'],
|
||||||
version: 1,
|
version: 1,
|
||||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
|
@ -200,6 +200,16 @@ export class Telegram implements INodeType {
|
||||||
value: 'editMessageText',
|
value: 'editMessageText',
|
||||||
description: 'Edit a text message',
|
description: 'Edit a text message',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Pin Chat Message',
|
||||||
|
value: 'pinChatMessage',
|
||||||
|
description: 'Pin a chat message',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Unpin Chat Message',
|
||||||
|
value: 'unpinChatMessage',
|
||||||
|
description: 'Unpin a chat message',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Send Animation',
|
name: 'Send Animation',
|
||||||
value: 'sendAnimation',
|
value: 'sendAnimation',
|
||||||
|
@ -266,6 +276,8 @@ export class Telegram implements INodeType {
|
||||||
'get',
|
'get',
|
||||||
'leave',
|
'leave',
|
||||||
'member',
|
'member',
|
||||||
|
'pinChatMessage',
|
||||||
|
'unpinChatMessage',
|
||||||
'setDescription',
|
'setDescription',
|
||||||
'setTitle',
|
'setTitle',
|
||||||
'sendAnimation',
|
'sendAnimation',
|
||||||
|
@ -288,6 +300,54 @@ export class Telegram implements INodeType {
|
||||||
description: 'Unique identifier for the target chat or username of the target<br />channel (in the format @channelusername).',
|
description: 'Unique identifier for the target chat or username of the target<br />channel (in the format @channelusername).',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// message:pinChatMessage
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Message ID',
|
||||||
|
name: 'messageId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'pinChatMessage',
|
||||||
|
'unpinChatMessage',
|
||||||
|
],
|
||||||
|
resource: [
|
||||||
|
'message',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
description: 'Unique identifier of the message to pin or unpin.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Additional Fields',
|
||||||
|
name: 'additionalFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'pinChatMessage',
|
||||||
|
],
|
||||||
|
resource: [
|
||||||
|
'message',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Disable Notification',
|
||||||
|
name: 'disable_notification',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: 'Do not send a notification to all chat members about the new pinned message.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// chat
|
// chat
|
||||||
|
@ -1622,6 +1682,30 @@ export class Telegram implements INodeType {
|
||||||
// Add additional fields and replyMarkup
|
// Add additional fields and replyMarkup
|
||||||
addAdditionalFields.call(this, body, i);
|
addAdditionalFields.call(this, body, i);
|
||||||
|
|
||||||
|
} else if (operation === 'pinChatMessage') {
|
||||||
|
// ----------------------------------
|
||||||
|
// message:pinChatMessage
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
endpoint = 'pinChatMessage';
|
||||||
|
|
||||||
|
body.chat_id = this.getNodeParameter('chatId', i) as string;
|
||||||
|
body.message_id = this.getNodeParameter('messageId', i) as string;
|
||||||
|
|
||||||
|
const { disable_notification } = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
if (disable_notification) {
|
||||||
|
body.disable_notification = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (operation === 'unpinChatMessage') {
|
||||||
|
// ----------------------------------
|
||||||
|
// message:unpinChatMessage
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
endpoint = 'unpinChatMessage';
|
||||||
|
|
||||||
|
body.chat_id = this.getNodeParameter('chatId', i) as string;
|
||||||
|
body.message_id = this.getNodeParameter('messageId', i) as string;
|
||||||
|
|
||||||
} else if (operation === 'sendAnimation') {
|
} else if (operation === 'sendAnimation') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
|
@ -23,7 +23,7 @@ export class TelegramTrigger implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'Telegram Trigger',
|
displayName: 'Telegram Trigger',
|
||||||
name: 'telegramTrigger',
|
name: 'telegramTrigger',
|
||||||
icon: 'file:telegram.png',
|
icon: 'file:telegram.svg',
|
||||||
group: ['trigger'],
|
group: ['trigger'],
|
||||||
version: 1,
|
version: 1,
|
||||||
subtitle: '=Updates: {{$parameter["updates"].join(", ")}}',
|
subtitle: '=Updates: {{$parameter["updates"].join(", ")}}',
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
1
packages/nodes-base/nodes/Telegram/telegram.svg
Normal file
1
packages/nodes-base/nodes/Telegram/telegram.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 66 66" fill="#fff" fill-rule="evenodd" stroke="#000" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="#A" x=".5" y=".5"/><symbol id="A" overflow="visible"><g stroke="none" fill-rule="nonzero"><path d="M0 32c0 17.673 14.327 32 32 32s32-14.327 32-32S49.673 0 32 0 0 14.327 0 32" fill="#37aee2"/><path d="M21.661 34.338l3.797 10.508s.475.983.983.983 8.068-7.864 8.068-7.864l8.407-16.237-21.119 9.898z" fill="#c8daea"/><path d="M26.695 37.034l-.729 7.746s-.305 2.373 2.068 0l4.644-4.203" fill="#a9c6d8"/><path d="M21.73 34.712l-7.809-2.545s-.932-.378-.633-1.237c.062-.177.186-.328.559-.588 1.731-1.206 32.028-12.096 32.028-12.096s.856-.288 1.361-.097c.231.088.378.187.503.548.045.132.071.411.068.689-.003.201-.027.386-.045.678-.184 2.978-5.706 25.198-5.706 25.198s-.33 1.3-1.514 1.345c-.432.016-.956-.071-1.582-.61-2.323-1.998-10.352-7.394-12.126-8.58-.1-.067-.129-.154-.146-.239-.025-.125.108-.28.108-.28s13.98-12.427 14.352-13.731c.029-.101-.079-.151-.226-.107-.929.342-17.025 10.506-18.801 11.629-.104.066-.395.023-.395.023"/></g></symbol></svg>
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue