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:
Iván Ovejero
2021-02-04 05:50:39 -03:00
committed by GitHub
parent eb2f14d06d
commit 049bf6bee8
4 changed files with 91 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ export class Telegram implements INodeType {
description: INodeTypeDescription = {
displayName: 'Telegram',
name: 'telegram',
icon: 'file:telegram.png',
icon: 'file:telegram.svg',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
@@ -200,6 +200,16 @@ export class Telegram implements INodeType {
value: 'editMessageText',
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',
value: 'sendAnimation',
@@ -266,6 +276,8 @@ export class Telegram implements INodeType {
'get',
'leave',
'member',
'pinChatMessage',
'unpinChatMessage',
'setDescription',
'setTitle',
'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).',
},
// ----------------------------------
// 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
@@ -1583,10 +1643,10 @@ export class Telegram implements INodeType {
body.title = this.getNodeParameter('title', i) as string;
}
// } else if (resource === 'bot') {
// if (operation === 'info') {
// endpoint = 'getUpdates';
// }
// } else if (resource === 'bot') {
// if (operation === 'info') {
// endpoint = 'getUpdates';
// }
} else if (resource === 'file') {
if (operation === 'get') {
@@ -1622,6 +1682,30 @@ export class Telegram implements INodeType {
// Add additional fields and replyMarkup
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') {
// ----------------------------------