2023-01-27 01:30:10 -08:00
import type { Readable } from 'stream' ;
2019-10-04 03:35:06 -07:00
2023-01-27 03:22:44 -08:00
import type {
2023-03-09 09:13:15 -08:00
IExecuteFunctions ,
2019-10-04 03:35:06 -07:00
IDataObject ,
INodeExecutionData ,
INodeType ,
2020-10-01 05:01:39 -07:00
INodeTypeDescription ,
2019-10-04 03:35:06 -07:00
} from 'n8n-workflow' ;
2023-03-09 09:13:15 -08:00
import { BINARY_ENCODING , NodeOperationError } from 'n8n-workflow' ;
2019-10-04 03:35:06 -07:00
2022-08-17 08:50:24 -07:00
import { addAdditionalFields , apiRequest , getPropertyName } from './GenericFunctions' ;
2019-10-04 03:35:06 -07:00
export class Telegram implements INodeType {
description : INodeTypeDescription = {
displayName : 'Telegram' ,
name : 'telegram' ,
2021-02-04 00:50:39 -08:00
icon : 'file:telegram.svg' ,
2019-10-04 03:35:06 -07:00
group : [ 'output' ] ,
version : 1 ,
subtitle : '={{$parameter["operation"] + ": " + $parameter["resource"]}}' ,
2021-07-03 05:40:16 -07:00
description : 'Sends data to Telegram' ,
2019-10-04 03:35:06 -07:00
defaults : {
name : 'Telegram' ,
} ,
inputs : [ 'main' ] ,
outputs : [ 'main' ] ,
credentials : [
{
name : 'telegramApi' ,
required : true ,
2020-10-22 06:46:03 -07:00
} ,
2019-10-04 03:35:06 -07:00
] ,
properties : [
{
displayName : 'Resource' ,
name : 'resource' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-10-04 03:35:06 -07:00
options : [
2021-01-04 17:18:51 -08:00
// {
// name: 'Bot',
// value: 'bot',
// },
2019-10-04 03:35:06 -07:00
{
name : 'Chat' ,
value : 'chat' ,
} ,
{
name : 'Callback' ,
value : 'callback' ,
} ,
2020-12-29 04:28:50 -08:00
{
name : 'File' ,
value : 'file' ,
} ,
2019-10-04 03:35:06 -07:00
{
name : 'Message' ,
value : 'message' ,
2020-10-22 06:46:03 -07:00
} ,
2019-10-04 03:35:06 -07:00
] ,
default : 'message' ,
} ,
2020-12-30 06:58:52 -08:00
// ----------------------------------
// operation
// ----------------------------------
2019-10-04 03:35:06 -07:00
2021-01-04 17:18:51 -08:00
// {
// displayName: 'Operation',
// name: 'operation',
// type: 'options',
// displayOptions: {
// show: {
// resource: [
// 'bot',
// ],
// },
// },
// options: [
// {
// name: 'Info',
// value: 'info',
// description: 'Get information about the bot associated with the access token.',
// },
// ],
// default: 'info',
// description: 'The operation to perform.',
// },
2019-10-04 03:35:06 -07:00
// ----------------------------------
// operation
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-10-04 03:35:06 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'chat' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
options : [
{
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get up to date information about a chat' ,
2022-07-10 13:50:51 -07:00
action : 'Get a chat' ,
2019-10-04 03:35:06 -07:00
} ,
{
2022-05-02 01:00:29 -07:00
name : 'Get Administrators' ,
value : 'administrators' ,
2022-05-06 14:01:25 -07:00
description : 'Get the Administrators of a chat' ,
2022-07-10 13:50:51 -07:00
action : 'Get all administrators in a chat' ,
2019-10-04 03:35:06 -07:00
} ,
{
2022-05-02 01:00:29 -07:00
name : 'Get Member' ,
2019-10-04 03:35:06 -07:00
value : 'member' ,
2022-05-06 14:01:25 -07:00
description : 'Get the member of a chat' ,
2022-07-10 13:50:51 -07:00
action : 'Get a member in a chat' ,
2019-10-04 03:35:06 -07:00
} ,
2022-05-02 01:00:29 -07:00
{
name : 'Leave' ,
value : 'leave' ,
2022-05-06 14:01:25 -07:00
description : 'Leave a group, supergroup or channel' ,
2022-07-10 13:50:51 -07:00
action : 'Leave a chat' ,
2022-05-02 01:00:29 -07:00
} ,
2019-10-04 03:35:06 -07:00
{
name : 'Set Description' ,
value : 'setDescription' ,
2022-05-06 14:01:25 -07:00
description : 'Set the description of a chat' ,
2022-07-10 13:50:51 -07:00
action : 'Set description on a chat' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Set Title' ,
value : 'setTitle' ,
2022-05-06 14:01:25 -07:00
description : 'Set the title of a chat' ,
2022-07-10 13:50:51 -07:00
action : 'Set a title on a chat' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
default : 'get' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-10-04 03:35:06 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'callback' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
options : [
{
name : 'Answer Query' ,
value : 'answerQuery' ,
2022-05-06 14:01:25 -07:00
description : 'Send answer to callback query sent from inline keyboard' ,
2022-07-10 13:50:51 -07:00
action : 'Answer Query a callback' ,
2019-10-04 03:35:06 -07:00
} ,
2021-03-24 10:51:00 -07:00
{
name : 'Answer Inline Query' ,
value : 'answerInlineQuery' ,
2022-05-06 14:01:25 -07:00
description : 'Send answer to callback query sent from inline bot' ,
2022-07-10 13:50:51 -07:00
action : 'Answer an inline query callback' ,
2021-03-24 10:51:00 -07:00
} ,
2019-10-04 03:35:06 -07:00
] ,
default : 'answerQuery' ,
} ,
2020-12-29 04:28:50 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-12-29 04:28:50 -08:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'file' ] ,
2020-12-29 04:28:50 -08:00
} ,
} ,
options : [
{
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get a file' ,
2022-07-10 13:50:51 -07:00
action : 'Get a file' ,
2020-12-29 04:28:50 -08:00
} ,
] ,
default : 'get' ,
} ,
2019-10-04 03:35:06 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-10-04 03:35:06 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
options : [
2021-07-10 03:36:21 -07:00
{
name : 'Delete Chat Message' ,
value : 'deleteMessage' ,
description : 'Delete a chat message' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a chat message' ,
2021-07-10 03:36:21 -07:00
} ,
2019-10-06 01:07:19 -07:00
{
name : 'Edit Message Text' ,
value : 'editMessageText' ,
description : 'Edit a text message' ,
2022-07-10 13:50:51 -07:00
action : 'Edit a test message' ,
2019-10-06 01:07:19 -07:00
} ,
2021-02-04 00:50:39 -08:00
{
name : 'Pin Chat Message' ,
value : 'pinChatMessage' ,
description : 'Pin a chat message' ,
2022-07-10 13:50:51 -07:00
action : 'Pin a chat message' ,
2021-02-04 00:50:39 -08:00
} ,
2020-09-04 01:30:49 -07:00
{
name : 'Send Animation' ,
value : 'sendAnimation' ,
description : 'Send an animated file' ,
2022-07-10 13:50:51 -07:00
action : 'Send an animated file' ,
2020-09-04 01:30:49 -07:00
} ,
2019-10-04 03:35:06 -07:00
{
name : 'Send Audio' ,
value : 'sendAudio' ,
description : 'Send a audio file' ,
2022-07-10 13:50:51 -07:00
action : 'Send an audio file' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Send Chat Action' ,
value : 'sendChatAction' ,
description : 'Send a chat action' ,
2022-07-10 13:50:51 -07:00
action : 'Send a chat action' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Send Document' ,
value : 'sendDocument' ,
description : 'Send a document' ,
2022-07-10 13:50:51 -07:00
action : 'Send a document' ,
2019-10-04 03:35:06 -07:00
} ,
2021-02-19 03:33:20 -08:00
{
name : 'Send Location' ,
value : 'sendLocation' ,
2021-02-21 12:51:39 -08:00
description : 'Send a location' ,
2022-07-10 13:50:51 -07:00
action : 'Send a location' ,
2021-02-19 03:33:20 -08:00
} ,
2019-12-13 11:05:21 -08:00
{
name : 'Send Media Group' ,
value : 'sendMediaGroup' ,
description : 'Send group of photos or videos to album' ,
2022-07-10 13:50:51 -07:00
action : 'Send a media group message' ,
2019-12-13 11:05:21 -08:00
} ,
2021-07-10 03:36:21 -07:00
{
name : 'Send Message' ,
value : 'sendMessage' ,
description : 'Send a text message' ,
2022-07-10 13:50:51 -07:00
action : 'Send a text message' ,
2021-07-10 03:36:21 -07:00
} ,
2019-10-04 03:35:06 -07:00
{
name : 'Send Photo' ,
value : 'sendPhoto' ,
description : 'Send a photo' ,
2022-07-10 13:50:51 -07:00
action : 'Send a photo message' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Send Sticker' ,
value : 'sendSticker' ,
description : 'Send a sticker' ,
2022-07-10 13:50:51 -07:00
action : 'Send a sticker' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Send Video' ,
value : 'sendVideo' ,
description : 'Send a video' ,
2022-07-10 13:50:51 -07:00
action : 'Send a video' ,
2019-10-04 03:35:06 -07:00
} ,
2021-07-10 03:36:21 -07:00
{
name : 'Unpin Chat Message' ,
value : 'unpinChatMessage' ,
description : 'Unpin a chat message' ,
2022-07-10 13:50:51 -07:00
action : 'Unpin a chat message' ,
2021-07-10 03:36:21 -07:00
} ,
2019-10-04 03:35:06 -07:00
] ,
default : 'sendMessage' ,
} ,
// ----------------------------------
// chat / message
// ----------------------------------
{
displayName : 'Chat ID' ,
name : 'chatId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2019-10-06 01:07:19 -07:00
operation : [
2022-05-02 01:00:29 -07:00
'administrators' ,
2021-07-10 03:36:21 -07:00
'deleteMessage' ,
2019-11-30 12:50:36 -08:00
'get' ,
'leave' ,
'member' ,
2021-02-04 00:50:39 -08:00
'pinChatMessage' ,
2019-11-30 12:50:36 -08:00
'setDescription' ,
'setTitle' ,
2020-09-04 01:30:49 -07:00
'sendAnimation' ,
2019-10-06 01:07:19 -07:00
'sendAudio' ,
'sendChatAction' ,
'sendDocument' ,
2021-02-19 03:33:20 -08:00
'sendLocation' ,
2019-10-06 01:07:19 -07:00
'sendMessage' ,
2019-12-13 11:05:21 -08:00
'sendMediaGroup' ,
2019-10-06 01:07:19 -07:00
'sendPhoto' ,
'sendSticker' ,
'sendVideo' ,
2021-07-10 03:36:21 -07:00
'unpinChatMessage' ,
2019-10-06 01:07:19 -07:00
] ,
2022-08-17 08:50:24 -07:00
resource : [ 'chat' , 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
required : true ,
2022-08-17 08:50:24 -07:00
description :
'Unique identifier for the target chat or username of the target channel (in the format @channelusername)' ,
2019-10-04 03:35:06 -07:00
} ,
2021-07-10 03:36:21 -07:00
// ----------------------------------
// message:deleteMessage
// ----------------------------------
{
displayName : 'Message ID' ,
name : 'messageId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'deleteMessage' ] ,
resource : [ 'message' ] ,
2021-07-10 03:36:21 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier of the message to delete' ,
2021-07-10 03:36:21 -07:00
} ,
2021-02-04 00:50:39 -08:00
// ----------------------------------
// message:pinChatMessage
// ----------------------------------
{
displayName : 'Message ID' ,
name : 'messageId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'pinChatMessage' , 'unpinChatMessage' ] ,
resource : [ 'message' ] ,
2021-02-04 00:50:39 -08:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier of the message to pin or unpin' ,
2021-02-04 00:50:39 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'pinChatMessage' ] ,
resource : [ 'message' ] ,
2021-02-04 00:50:39 -08:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Disable Notification' ,
name : 'disable_notification' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether to send a notification to all chat members about the new pinned message' ,
2021-02-04 00:50:39 -08:00
} ,
] ,
} ,
2019-10-04 03:35:06 -07:00
// ----------------------------------
// chat
// ----------------------------------
// ----------------------------------
// chat:member
// ----------------------------------
{
displayName : 'User ID' ,
name : 'userId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'member' ] ,
resource : [ 'chat' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier of the target user' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// chat:setDescription
// ----------------------------------
{
displayName : 'Description' ,
name : 'description' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'setDescription' ] ,
resource : [ 'chat' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'New chat description, 0-255 characters' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// chat:setTitle
// ----------------------------------
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'setTitle' ] ,
resource : [ 'chat' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'New chat title, 1-255 characters' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// callback
// ----------------------------------
// ----------------------------------
// callback:answerQuery
// ----------------------------------
{
displayName : 'Query ID' ,
name : 'queryId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'answerQuery' ] ,
resource : [ 'callback' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier for the query to be answered' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'answerQuery' ] ,
resource : [ 'callback' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Cache Time' ,
name : 'cache_time' ,
type : 'number' ,
typeOptions : {
minValue : 0 ,
} ,
default : 0 ,
2022-08-17 08:50:24 -07:00
description :
'The maximum amount of time in seconds that the result of the callback query may be cached client-side' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Show Alert' ,
name : 'show_alert' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether an alert will be shown by the client instead of a notification at the top of the chat screen' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'URL' ,
name : 'url' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description : "URL that will be opened by the user's client" ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
2021-03-24 10:51:00 -07:00
// -----------------------------------------------
// callback:answerInlineQuery
// -----------------------------------------------
{
displayName : 'Query ID' ,
name : 'queryId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'answerInlineQuery' ] ,
resource : [ 'callback' ] ,
2021-03-24 10:51:00 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier for the answered query' ,
2021-03-24 10:51:00 -07:00
} ,
{
displayName : 'Results' ,
name : 'results' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'answerInlineQuery' ] ,
resource : [ 'callback' ] ,
2021-03-24 10:51:00 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'A JSON-serialized array of results for the inline query' ,
2021-03-24 10:51:43 -07:00
} ,
2021-03-24 10:51:00 -07:00
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'answerInlineQuery' ] ,
resource : [ 'callback' ] ,
2021-03-24 10:51:00 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Cache Time' ,
name : 'cache_time' ,
type : 'number' ,
typeOptions : {
minValue : 0 ,
} ,
default : 0 ,
2022-08-17 08:50:24 -07:00
description :
'The maximum amount of time in seconds that the result of the callback query may be cached client-side' ,
2021-03-24 10:51:00 -07:00
} ,
{
displayName : 'Show Alert' ,
name : 'show_alert' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether an alert will be shown by the client instead of a notification at the top of the chat screen' ,
2021-03-24 10:51:00 -07:00
} ,
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.' ,
2021-03-24 10:51:00 -07:00
} ,
{
displayName : 'URL' ,
name : 'url' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description : "URL that will be opened by the user's client" ,
2021-03-24 10:51:00 -07:00
} ,
] ,
} ,
2019-10-04 03:35:06 -07:00
2020-12-29 04:28:50 -08:00
// ----------------------------------
// file
// ----------------------------------
// ----------------------------------
// file:get/download
// ----------------------------------
{
displayName : 'File ID' ,
name : 'fileId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'file' ] ,
2020-12-29 04:28:50 -08:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the file' ,
2020-12-29 04:28:50 -08:00
} ,
{
displayName : 'Download' ,
name : 'download' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'file' ] ,
2020-12-29 04:28:50 -08:00
} ,
} ,
default : true ,
2022-06-20 07:54:01 -07:00
description : 'Whether to download the file' ,
2020-12-29 04:28:50 -08:00
} ,
2019-10-04 03:35:06 -07:00
// ----------------------------------
// message
// ----------------------------------
2019-10-06 01:07:19 -07:00
// ----------------------------------
// message:editMessageText
// ----------------------------------
{
displayName : 'Message Type' ,
name : 'messageType' ,
type : 'options' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'editMessageText' ] ,
resource : [ 'message' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
options : [
{
name : 'Inline Message' ,
value : 'inlineMessage' ,
} ,
{
name : 'Message' ,
value : 'message' ,
} ,
] ,
default : 'message' ,
2022-05-06 14:01:25 -07:00
description : 'The type of the message to edit' ,
2019-10-06 01:07:19 -07:00
} ,
{
displayName : 'Chat ID' ,
name : 'chatId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
messageType : [ 'message' ] ,
operation : [ 'editMessageText' ] ,
resource : [ 'message' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
required : true ,
2022-08-17 08:50:24 -07:00
description :
'Unique identifier for the target chat or username of the target channel (in the format @channelusername). To find your chat ID ask @get_id_bot.' ,
2019-10-06 01:07:19 -07:00
} ,
2021-09-27 15:47:39 -07:00
// ----------------------------------
// message:sendAnimation/sendAudio/sendDocument/sendPhoto/sendSticker/sendVideo
// ----------------------------------
{
displayName : 'Binary Data' ,
name : 'binaryData' ,
type : 'boolean' ,
default : false ,
required : true ,
displayOptions : {
show : {
operation : [
'sendAnimation' ,
'sendAudio' ,
'sendDocument' ,
'sendPhoto' ,
'sendVideo' ,
'sendSticker' ,
] ,
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
2021-09-27 15:47:39 -07:00
} ,
} ,
2022-06-20 07:54:01 -07:00
description : 'Whether the data to upload should be taken from binary field' ,
2021-09-27 15:47:39 -07:00
} ,
{
displayName : 'Binary Property' ,
name : 'binaryPropertyName' ,
type : 'string' ,
default : 'data' ,
required : true ,
displayOptions : {
show : {
operation : [
'sendAnimation' ,
'sendAudio' ,
'sendDocument' ,
'sendPhoto' ,
'sendVideo' ,
'sendSticker' ,
] ,
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
binaryData : [ true ] ,
2021-09-27 15:47:39 -07:00
} ,
} ,
placeholder : '' ,
description : 'Name of the binary property that contains the data to upload' ,
} ,
2019-10-06 01:07:19 -07:00
{
displayName : 'Message ID' ,
name : 'messageId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
messageType : [ 'message' ] ,
operation : [ 'editMessageText' ] ,
resource : [ 'message' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier of the message to edit' ,
2019-10-06 01:07:19 -07:00
} ,
{
displayName : 'Inline Message ID' ,
name : 'inlineMessageId' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
messageType : [ 'inlineMessage' ] ,
operation : [ 'editMessageText' ] ,
resource : [ 'message' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Unique identifier of the inline message to edit' ,
2019-10-06 01:07:19 -07:00
} ,
{
displayName : 'Reply Markup' ,
name : 'replyMarkup' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'editMessageText' ] ,
resource : [ 'message' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
type : 'options' ,
options : [
{
name : 'None' ,
value : 'none' ,
} ,
{
name : 'Inline Keyboard' ,
value : 'inlineKeyboard' ,
} ,
] ,
default : 'none' ,
2022-05-06 14:01:25 -07:00
description : 'Additional interface options' ,
2019-10-06 01:07:19 -07:00
} ,
2020-09-04 01:30:49 -07:00
// ----------------------------------
// message:sendAnimation
// ----------------------------------
{
displayName : 'Animation' ,
name : 'file' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendAnimation' ] ,
resource : [ 'message' ] ,
binaryData : [ false ] ,
2020-09-04 01:30:49 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Animation to send. Pass a file_id to send an animation that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get an animation from the Internet.' ,
2020-09-04 01:30:49 -07:00
} ,
2019-10-04 03:35:06 -07:00
// ----------------------------------
// message:sendAudio
// ----------------------------------
{
displayName : 'Audio' ,
name : 'file' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendAudio' ] ,
resource : [ 'message' ] ,
binaryData : [ false ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
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.' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// message:sendChatAction
// ----------------------------------
{
displayName : 'Action' ,
name : 'action' ,
type : 'options' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendChatAction' ] ,
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
options : [
{
name : 'Find Location' ,
value : 'find_location' ,
2022-07-10 13:50:51 -07:00
action : 'Find location' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Record Audio' ,
value : 'record_audio' ,
2022-07-10 13:50:51 -07:00
action : 'Record audio' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Record Video' ,
value : 'record_video' ,
2022-07-10 13:50:51 -07:00
action : 'Record video' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Record Video Note' ,
value : 'record_video_note' ,
2022-07-10 13:50:51 -07:00
action : 'Record video note' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Typing' ,
value : 'typing' ,
2022-07-10 13:50:51 -07:00
action : 'Typing a message' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Upload Audio' ,
value : 'upload_audio' ,
2022-07-10 13:50:51 -07:00
action : 'Upload audio' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Upload Document' ,
value : 'upload_document' ,
2022-07-10 13:50:51 -07:00
action : 'Upload document' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Upload Photo' ,
value : 'upload_photo' ,
2022-07-10 13:50:51 -07:00
action : 'Upload photo' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Upload Video' ,
value : 'upload_video' ,
2022-07-10 13:50:51 -07:00
action : 'Upload video' ,
2019-10-04 03:35:06 -07:00
} ,
{
name : 'Upload Video Note' ,
value : 'upload_video_note' ,
2022-07-10 13:50:51 -07:00
action : 'Upload video note' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
default : 'typing' ,
2022-08-17 08:50:24 -07:00
description :
'Type of action to broadcast. Choose one, depending on what the user is about to receive. The status is set for 5 seconds or less (when a message arrives from your bot).' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// message:sendDocument
// ----------------------------------
{
displayName : 'Document' ,
name : 'file' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendDocument' ] ,
resource : [ 'message' ] ,
binaryData : [ false ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Document 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.' ,
2019-10-04 03:35:06 -07:00
} ,
2021-02-19 03:33:20 -08:00
// ----------------------------------
// message:sendLocation
// ----------------------------------
{
displayName : 'Latitude' ,
name : 'latitude' ,
type : 'number' ,
default : 0.0 ,
typeOptions : {
numberPrecision : 10 ,
minValue : - 90 ,
2021-02-21 12:51:39 -08:00
maxValue : 90 ,
2021-02-19 03:33:20 -08:00
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendLocation' ] ,
resource : [ 'message' ] ,
2021-02-21 12:51:39 -08:00
} ,
2021-02-19 03:33:20 -08:00
} ,
2021-02-21 12:51:39 -08:00
description : 'Location latitude' ,
2021-02-19 03:33:20 -08:00
} ,
{
displayName : 'Longitude' ,
name : 'longitude' ,
type : 'number' ,
typeOptions : {
numberPrecision : 10 ,
minValue : - 180 ,
2021-02-21 12:51:39 -08:00
maxValue : 180 ,
2021-02-19 03:33:20 -08:00
} ,
default : 0.0 ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendLocation' ] ,
resource : [ 'message' ] ,
2021-02-21 12:51:39 -08:00
} ,
2021-02-19 03:33:20 -08:00
} ,
2021-02-21 12:51:39 -08:00
description : 'Location longitude' ,
2021-02-19 03:33:20 -08:00
} ,
2019-12-13 11:05:21 -08:00
// ----------------------------------
// message:sendMediaGroup
// ----------------------------------
{
displayName : 'Media' ,
name : 'media' ,
type : 'fixedCollection' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendMediaGroup' ] ,
resource : [ 'message' ] ,
2019-12-13 11:05:21 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The media to add' ,
2019-12-13 11:05:21 -08:00
placeholder : 'Add Media' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
options : [
{
displayName : 'Media' ,
name : 'media' ,
values : [
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'Photo' ,
value : 'photo' ,
} ,
{
name : 'Video' ,
value : 'video' ,
} ,
] ,
default : 'photo' ,
2022-05-06 14:01:25 -07:00
description : 'The type of the media to add' ,
2019-12-13 11:05:21 -08:00
} ,
{
displayName : 'Media File' ,
name : 'media' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Media to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass an HTTP URL for Telegram to get a file from the Internet.' ,
2019-12-13 11:05:21 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
options : [
{
displayName : 'Caption' ,
name : 'caption' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Caption text to set, 0-1024 characters' ,
2019-12-13 11:05:21 -08:00
} ,
{
displayName : 'Parse Mode' ,
name : 'parse_mode' ,
type : 'options' ,
options : [
{
name : 'Markdown' ,
value : 'Markdown' ,
} ,
{
name : 'HTML' ,
value : 'HTML' ,
} ,
] ,
default : 'HTML' ,
2022-05-06 14:01:25 -07:00
description : 'How to parse the text' ,
2019-12-13 11:05:21 -08:00
} ,
] ,
} ,
] ,
} ,
] ,
} ,
2019-10-04 03:35:06 -07:00
// ----------------------------------
// message:sendMessage
// ----------------------------------
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'editMessageText' , 'sendMessage' ] ,
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Text of the message to be sent' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// message:sendPhoto
// ----------------------------------
{
displayName : 'Photo' ,
name : 'file' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendPhoto' ] ,
resource : [ 'message' ] ,
binaryData : [ false ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Photo to send. Pass a file_id to send a photo that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a photo from the Internet.' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// message:sendSticker
// ----------------------------------
{
displayName : 'Sticker' ,
name : 'file' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendSticker' ] ,
resource : [ 'message' ] ,
binaryData : [ false ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Sticker 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 .webp file from the Internet.' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
// message:sendVideo
// ----------------------------------
{
displayName : 'Video' ,
name : 'file' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'sendVideo' ] ,
resource : [ 'message' ] ,
binaryData : [ false ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
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.' ,
2019-10-04 03:35:06 -07:00
} ,
// ----------------------------------
2021-02-19 03:33:20 -08:00
// message:editMessageText/sendAnimation/sendAudio/sendLocation/sendMessage/sendPhoto/sendSticker/sendVideo
2019-10-04 03:35:06 -07:00
// ----------------------------------
{
displayName : 'Reply Markup' ,
name : 'replyMarkup' ,
displayOptions : {
show : {
operation : [
2020-09-04 01:30:49 -07:00
'sendAnimation' ,
2019-10-04 03:35:06 -07:00
'sendDocument' ,
'sendMessage' ,
'sendPhoto' ,
'sendSticker' ,
'sendVideo' ,
2020-12-30 06:58:52 -08:00
'sendAudio' ,
2021-02-21 12:51:39 -08:00
'sendLocation' ,
2019-10-04 03:35:06 -07:00
] ,
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
type : 'options' ,
options : [
{
name : 'Force Reply' ,
value : 'forceReply' ,
} ,
{
name : 'Inline Keyboard' ,
value : 'inlineKeyboard' ,
} ,
2022-06-03 10:23:49 -07:00
{
name : 'None' ,
value : 'none' ,
} ,
2019-10-04 03:35:06 -07:00
{
name : 'Reply Keyboard' ,
value : 'replyKeyboard' ,
} ,
{
name : 'Reply Keyboard Remove' ,
value : 'replyKeyboardRemove' ,
} ,
] ,
default : 'none' ,
2022-05-06 14:01:25 -07:00
description : 'Additional interface options' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Force Reply' ,
name : 'forceReply' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
replyMarkup : [ 'forceReply' ] ,
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Force Reply' ,
name : 'force_reply' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether to show reply interface to the user, as if they manually selected the bot‘ s message and tapped ’ Reply' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Selective' ,
name : 'selective' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to force reply from specific users only' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
{
displayName : 'Inline Keyboard' ,
name : 'inlineKeyboard' ,
placeholder : 'Add Keyboard Row' ,
2022-05-06 14:01:25 -07:00
description : 'Adds an inline keyboard that appears right next to the message it belongs to' ,
2019-10-04 03:35:06 -07:00
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
replyMarkup : [ 'inlineKeyboard' ] ,
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Rows' ,
name : 'rows' ,
values : [
{
displayName : 'Row' ,
name : 'row' ,
type : 'fixedCollection' ,
2022-05-06 14:01:25 -07:00
description : 'The value to set' ,
2019-10-04 03:35:06 -07:00
placeholder : 'Add Button' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
options : [
{
displayName : 'Buttons' ,
name : 'buttons' ,
values : [
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Label text on the button' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
options : [
{
displayName : 'Callback Data' ,
name : 'callback_data' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Pay' ,
name : 'pay' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to send a Pay button' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Switch Inline Query Current Chat' ,
name : 'switch_inline_query_current_chat' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
"If set, pressing the button will insert the bot‘ s username and the specified inline query in the current chat's input field.Can be empty, in which case only the bot’ s username will be inserted" ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Switch Inline Query' ,
name : 'switch_inline_query' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘ s username and the specified inline query in the input field. Can be empty, in which case just the bot’ s username will be inserted.' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'URL' ,
name : 'url' ,
type : 'string' ,
default : '' ,
2022-06-03 10:23:49 -07:00
description : 'HTTP or tg:// URL to be opened when button is pressed' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Reply Keyboard' ,
name : 'replyKeyboard' ,
placeholder : 'Add Reply Keyboard Row' ,
2022-05-06 14:01:25 -07:00
description : 'Adds a custom keyboard with reply options' ,
2019-10-04 03:35:06 -07:00
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
replyMarkup : [ 'replyKeyboard' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Rows' ,
name : 'rows' ,
values : [
{
displayName : 'Row' ,
name : 'row' ,
type : 'fixedCollection' ,
2022-05-06 14:01:25 -07:00
description : 'The value to set' ,
2019-10-04 03:35:06 -07:00
placeholder : 'Add Button' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
options : [
{
displayName : 'Buttons' ,
name : 'buttons' ,
values : [
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
options : [
{
displayName : 'Request Contact' ,
name : 'request_contact' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
"Whether the user's phone number will be sent as a contact when the button is pressed.Available in private chats only" ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Request Location' ,
name : 'request_location' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description : "Whether the user's request_location" ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Reply Keyboard Options' ,
name : 'replyKeyboardOptions' ,
type : 'collection' ,
placeholder : 'Add Option' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
replyMarkup : [ 'replyKeyboard' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Resize Keyboard' ,
name : 'resize_keyboard' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether to request clients to resize the keyboard vertically for optimal fit' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'One Time Keyboard' ,
name : 'one_time_keyboard' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
"Whether to request clients to hide the keyboard as soon as it's been used" ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Selective' ,
name : 'selective' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to show the keyboard to specific users only' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
{
displayName : 'Reply Keyboard Remove' ,
name : 'replyKeyboardRemove' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
replyMarkup : [ 'replyKeyboardRemove' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Remove Keyboard' ,
name : 'remove_keyboard' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to request clients to remove the custom keyboard' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Selective' ,
name : 'selective' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to force reply from specific users only' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
operation : [
2019-10-06 01:07:19 -07:00
'editMessageText' ,
2020-09-04 01:30:49 -07:00
'sendAnimation' ,
2020-12-29 02:55:31 -08:00
'sendAudio' ,
2019-10-04 03:35:06 -07:00
'sendDocument' ,
2021-02-19 03:33:20 -08:00
'sendLocation' ,
2019-10-04 03:35:06 -07:00
'sendMessage' ,
2019-12-13 11:05:21 -08:00
'sendMediaGroup' ,
2019-10-04 03:35:06 -07:00
'sendPhoto' ,
'sendSticker' ,
'sendVideo' ,
] ,
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Caption' ,
name : 'caption' ,
type : 'string' ,
displayOptions : {
show : {
'/operation' : [
2020-09-04 01:30:49 -07:00
'sendAnimation' ,
2019-10-04 03:35:06 -07:00
'sendAudio' ,
'sendDocument' ,
'sendPhoto' ,
'sendVideo' ,
] ,
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Caption text to set, 0-1024 characters' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Disable Notification' ,
name : 'disable_notification' ,
type : 'boolean' ,
default : false ,
2019-10-06 01:07:19 -07:00
displayOptions : {
hide : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'editMessageText' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
'Whether to send the message silently. Users will receive a notification with no sound.' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Disable WebPage Preview' ,
name : 'disable_web_page_preview' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'editMessageText' , 'sendMessage' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to disable link previews for links in this message' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Duration' ,
name : 'duration' ,
type : 'number' ,
typeOptions : {
minValue : 0 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'sendAnimation' , 'sendAudio' , 'sendVideo' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : 0 ,
2022-05-06 14:01:25 -07:00
description : 'Duration of clip in seconds' ,
2019-10-04 03:35:06 -07:00
} ,
2022-07-10 01:07:16 -07:00
{
displayName : 'File Name' ,
name : 'fileName' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
'/operation' : [
'sendAnimation' ,
'sendAudio' ,
'sendDocument' ,
'sendPhoto' ,
'sendVideo' ,
'sendSticker' ,
] ,
2022-08-17 08:50:24 -07:00
'/resource' : [ 'message' ] ,
'/binaryData' : [ true ] ,
2022-07-10 01:07:16 -07:00
} ,
} ,
placeholder : 'image.jpeg' ,
} ,
2019-10-04 03:35:06 -07:00
{
displayName : 'Height' ,
name : 'height' ,
type : 'number' ,
typeOptions : {
minValue : 0 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'sendAnimation' , 'sendVideo' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : 0 ,
2022-05-06 14:01:25 -07:00
description : 'Height of the video' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Parse Mode' ,
name : 'parse_mode' ,
type : 'options' ,
options : [
{
name : 'Markdown' ,
value : 'Markdown' ,
} ,
{
name : 'HTML' ,
value : 'HTML' ,
} ,
] ,
displayOptions : {
show : {
'/operation' : [
2019-10-06 01:07:19 -07:00
'editMessageText' ,
2020-09-04 01:30:49 -07:00
'sendAnimation' ,
2019-10-04 03:35:06 -07:00
'sendAudio' ,
'sendMessage' ,
'sendPhoto' ,
'sendVideo' ,
2023-03-01 06:47:09 -08:00
'sendDocument' ,
2019-10-04 03:35:06 -07:00
] ,
} ,
} ,
default : 'HTML' ,
2022-05-06 14:01:25 -07:00
description : 'How to parse the text' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Performer' ,
name : 'performer' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'sendAudio' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Name of the performer' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Reply To Message ID' ,
name : 'reply_to_message_id' ,
type : 'number' ,
2019-10-06 01:07:19 -07:00
displayOptions : {
hide : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'editMessageText' ] ,
2019-10-06 01:07:19 -07:00
} ,
} ,
2019-10-04 03:35:06 -07:00
default : 0 ,
2022-05-06 14:01:25 -07:00
description : 'If the message is a reply, ID of the original message' ,
2019-10-04 03:35:06 -07:00
} ,
2023-07-13 03:03:26 -07:00
{
displayName : 'Message Thread ID' ,
name : 'message_thread_id' ,
type : 'number' ,
displayOptions : {
show : {
'/operation' : [
'sendAnimation' ,
'sendAudio' ,
'sendChatAction' ,
'sendDocument' ,
'sendLocation' ,
'sendMediaGroup' ,
'sendMessage' ,
'sendPhoto' ,
'sendSticker' ,
'sendVideo' ,
] ,
} ,
} ,
default : 0 ,
description : 'The unique identifier of the forum topic' ,
} ,
2019-10-04 03:35:06 -07:00
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'sendAudio' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Title of the track' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Thumbnail' ,
name : 'thumb' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'sendAnimation' , 'sendAudio' , 'sendDocument' , 'sendVideo' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘ s width and height should not exceed 320.' ,
2019-10-04 03:35:06 -07:00
} ,
{
displayName : 'Width' ,
name : 'width' ,
type : 'number' ,
typeOptions : {
minValue : 0 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
'/operation' : [ 'sendAnimation' , 'sendVideo' ] ,
2019-10-04 03:35:06 -07:00
} ,
} ,
default : 0 ,
2022-05-06 14:01:25 -07:00
description : 'Width of the video' ,
2019-10-04 03:35:06 -07:00
} ,
] ,
} ,
] ,
} ;
async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
const items = this . getInputData ( ) ;
2020-12-29 04:28:50 -08:00
const returnData : INodeExecutionData [ ] = [ ] ;
2019-10-04 03:35:06 -07:00
// For Post
let body : IDataObject ;
// For Query string
let qs : IDataObject ;
let requestMethod : string ;
let endpoint : string ;
2022-12-02 03:53:59 -08:00
const operation = this . getNodeParameter ( 'operation' , 0 ) ;
const resource = this . getNodeParameter ( 'resource' , 0 ) ;
2022-11-18 05:31:38 -08:00
const binaryData = this . getNodeParameter ( 'binaryData' , 0 , false ) ;
2019-10-04 03:35:06 -07:00
for ( let i = 0 ; i < items . length ; i ++ ) {
2021-07-19 23:58:54 -07:00
try {
// Reset all values
requestMethod = 'POST' ;
endpoint = '' ;
body = { } ;
qs = { } ;
2019-10-04 03:35:06 -07:00
2021-07-19 23:58:54 -07:00
if ( resource === 'callback' ) {
if ( operation === 'answerQuery' ) {
// ----------------------------------
// callback:answerQuery
// ----------------------------------
2019-10-04 03:35:06 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'answerCallbackQuery' ;
2019-10-04 03:35:06 -07:00
2021-07-19 23:58:54 -07:00
body . callback_query_id = this . getNodeParameter ( 'queryId' , i ) as string ;
2019-10-04 03:35:06 -07:00
2021-07-19 23:58:54 -07:00
// Add additional fields
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
2021-07-19 23:58:54 -07:00
Object . assign ( body , additionalFields ) ;
} else if ( operation === 'answerInlineQuery' ) {
// -----------------------------------------------
// callback:answerInlineQuery
// -----------------------------------------------
2021-03-24 10:51:00 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'answerInlineQuery' ;
2021-03-24 10:51:43 -07:00
2021-07-19 23:58:54 -07:00
body . inline_query_id = this . getNodeParameter ( 'queryId' , i ) as string ;
body . results = this . getNodeParameter ( 'results' , i ) as string ;
2021-03-24 10:51:43 -07:00
2021-07-19 23:58:54 -07:00
// Add additional fields
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
2021-07-19 23:58:54 -07:00
Object . assign ( body , additionalFields ) ;
}
} else if ( resource === 'chat' ) {
if ( operation === 'get' ) {
// ----------------------------------
// chat:get
// ----------------------------------
2020-12-29 04:28:50 -08:00
2021-07-19 23:58:54 -07:00
endpoint = 'getChat' ;
2020-12-29 04:28:50 -08:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2022-05-02 01:00:29 -07:00
} else if ( operation === 'administrators' ) {
// ----------------------------------
// chat:administrators
// ----------------------------------
endpoint = 'getChatAdministrators' ;
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-07-19 23:58:54 -07:00
} else if ( operation === 'leave' ) {
// ----------------------------------
// chat:leave
// ----------------------------------
2020-12-29 04:28:50 -08:00
2021-07-19 23:58:54 -07:00
endpoint = 'leaveChat' ;
2019-10-04 03:35:06 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
} else if ( operation === 'member' ) {
// ----------------------------------
// chat:member
// ----------------------------------
2019-10-06 01:07:19 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'getChatMember' ;
2019-10-06 01:07:19 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-07-19 23:58:54 -07:00
body . user_id = this . getNodeParameter ( 'userId' , i ) as string ;
} else if ( operation === 'setDescription' ) {
// ----------------------------------
// chat:setDescription
// ----------------------------------
2019-10-06 01:07:19 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'setChatDescription' ;
2021-07-10 03:36:21 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . description = this . getNodeParameter ( 'description' , i ) as string ;
} else if ( operation === 'setTitle' ) {
// ----------------------------------
// chat:setTitle
// ----------------------------------
2021-02-04 00:50:39 -08:00
2021-07-19 23:58:54 -07:00
endpoint = 'setChatTitle' ;
2021-02-04 00:50:39 -08:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . title = this . getNodeParameter ( 'title' , i ) as string ;
2021-02-04 00:50:39 -08:00
}
2021-07-19 23:58:54 -07:00
// } else if (resource === 'bot') {
// if (operation === 'info') {
// endpoint = 'getUpdates';
// }
} else if ( resource === 'file' ) {
if ( operation === 'get' ) {
// ----------------------------------
// file:get
// ----------------------------------
2021-02-19 03:33:20 -08:00
2021-07-19 23:58:54 -07:00
endpoint = 'getFile' ;
2021-02-19 03:33:20 -08:00
2021-07-19 23:58:54 -07:00
body . file_id = this . getNodeParameter ( 'fileId' , i ) as string ;
}
} else if ( resource === 'message' ) {
if ( operation === 'editMessageText' ) {
// ----------------------------------
// message:editMessageText
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'editMessageText' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
const messageType = this . getNodeParameter ( 'messageType' , i ) as string ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
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 ;
}
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . text = this . getNodeParameter ( 'text' , i ) as string ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'deleteMessage' ) {
// ----------------------------------
// message:deleteMessage
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'deleteMessage' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . message_id = this . getNodeParameter ( 'messageId' , i ) as string ;
} else if ( operation === 'pinChatMessage' ) {
// ----------------------------------
// message:pinChatMessage
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'pinChatMessage' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . message_id = this . getNodeParameter ( 'messageId' , i ) as string ;
2021-09-27 15:47:39 -07:00
2022-12-02 12:54:28 -08:00
const { disable_notification } = this . getNodeParameter ( 'additionalFields' , i ) ;
2021-07-19 23:58:54 -07:00
if ( disable_notification ) {
body . disable_notification = true ;
}
} else if ( operation === 'unpinChatMessage' ) {
// ----------------------------------
// message:unpinChatMessage
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'unpinChatMessage' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . message_id = this . getNodeParameter ( 'messageId' , i ) as string ;
} else if ( operation === 'sendAnimation' ) {
// ----------------------------------
// message:sendAnimation
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendAnimation' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
body . animation = this . getNodeParameter ( 'file' , i , '' ) as string ;
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendAudio' ) {
// ----------------------------------
// message:sendAudio
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendAudio' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
body . audio = this . getNodeParameter ( 'file' , i , '' ) as string ;
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendChatAction' ) {
// ----------------------------------
// message:sendChatAction
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendChatAction' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . action = this . getNodeParameter ( 'action' , i ) as string ;
} else if ( operation === 'sendDocument' ) {
// ----------------------------------
// message:sendDocument
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendDocument' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
body . document = this . getNodeParameter ( 'file' , i , '' ) as string ;
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendLocation' ) {
// ----------------------------------
// message:sendLocation
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendLocation' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . latitude = this . getNodeParameter ( 'latitude' , i ) as string ;
body . longitude = this . getNodeParameter ( 'longitude' , i ) as string ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendMessage' ) {
// ----------------------------------
// message:sendMessage
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendMessage' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
body . text = this . getNodeParameter ( 'text' , i ) as string ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendMediaGroup' ) {
// ----------------------------------
// message:sendMediaGroup
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendMediaGroup' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
2021-07-19 23:58:54 -07:00
Object . assign ( body , additionalFields ) ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
const mediaItems = this . getNodeParameter ( 'media' , i ) as IDataObject ;
body . media = [ ] ;
for ( const mediaItem of mediaItems . media as IDataObject [ ] ) {
if ( mediaItem . additionalFields !== undefined ) {
Object . assign ( mediaItem , mediaItem . additionalFields ) ;
delete mediaItem . additionalFields ;
}
( body . media as IDataObject [ ] ) . push ( mediaItem ) ;
2019-12-13 11:05:21 -08:00
}
2021-07-19 23:58:54 -07:00
} else if ( operation === 'sendPhoto' ) {
// ----------------------------------
// message:sendPhoto
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendPhoto' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
body . photo = this . getNodeParameter ( 'file' , i , '' ) as string ;
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendSticker' ) {
// ----------------------------------
// message:sendSticker
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendSticker' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
body . sticker = this . getNodeParameter ( 'file' , i , '' ) as string ;
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
} else if ( operation === 'sendVideo' ) {
// ----------------------------------
// message:sendVideo
// ----------------------------------
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
endpoint = 'sendVideo' ;
2021-09-27 15:47:39 -07:00
2021-07-19 23:58:54 -07:00
body . chat_id = this . getNodeParameter ( 'chatId' , i ) as string ;
2021-09-27 15:47:39 -07:00
body . video = this . getNodeParameter ( 'file' , i , '' ) as string ;
2021-07-19 23:58:54 -07:00
// Add additional fields and replyMarkup
addAdditionalFields . call ( this , body , i ) ;
2019-12-13 11:05:21 -08:00
}
2021-07-19 23:58:54 -07:00
} else {
2022-08-17 08:50:24 -07:00
throw new NodeOperationError ( this . getNode ( ) , ` The resource " ${ resource } " is not known! ` , {
itemIndex : i ,
} ) ;
2021-07-19 23:58:54 -07:00
}
2019-12-13 11:05:21 -08:00
2021-09-27 15:47:39 -07:00
let responseData ;
2022-12-02 12:54:28 -08:00
if ( binaryData ) {
2023-01-06 06:09:32 -08:00
const binaryPropertyName = this . getNodeParameter ( 'binaryPropertyName' , 0 ) ;
2022-12-02 12:54:28 -08:00
const itemBinaryData = items [ i ] . binary ! [ binaryPropertyName ] ;
2021-09-27 15:47:39 -07:00
const propertyName = getPropertyName ( operation ) ;
2022-07-10 01:07:16 -07:00
const fileName = this . getNodeParameter ( 'additionalFields.fileName' , 0 , '' ) as string ;
2022-12-02 12:54:28 -08:00
const filename = fileName || itemBinaryData . fileName ? . toString ( ) ;
2022-07-10 01:07:16 -07:00
2022-12-02 12:54:28 -08:00
if ( ! fileName && ! itemBinaryData . fileName ) {
2022-08-17 08:50:24 -07:00
throw new NodeOperationError (
this . getNode ( ) ,
` File name is needed to ${ operation } . Make sure the property that holds the binary data
2022-07-10 01:07:16 -07:00
has the file name property set or set it manually in the node using the File Name parameter under
2022-08-17 08:50:24 -07:00
Additional Fields . ` ,
) ;
2022-07-10 01:07:16 -07:00
}
2021-09-27 15:47:39 -07:00
2023-01-19 04:37:19 -08:00
body . disable_notification = body . disable_notification ? . toString ( ) || 'false' ;
2022-03-20 12:08:06 -07:00
2023-01-27 01:30:10 -08:00
let uploadData : Buffer | Readable ;
if ( itemBinaryData . id ) {
2023-09-25 07:59:45 -07:00
uploadData = await this . helpers . getBinaryStream ( itemBinaryData . id ) ;
2023-01-27 01:30:10 -08:00
} else {
uploadData = Buffer . from ( itemBinaryData . data , BINARY_ENCODING ) ;
}
2021-09-27 15:47:39 -07:00
const formData = {
. . . body ,
[ propertyName ] : {
2023-01-27 01:30:10 -08:00
value : uploadData ,
2021-09-27 15:47:39 -07:00
options : {
2022-07-10 01:07:16 -07:00
filename ,
2022-12-02 12:54:28 -08:00
contentType : itemBinaryData.mimeType ,
2021-09-27 15:47:39 -07:00
} ,
} ,
} ;
2022-07-10 01:07:16 -07:00
2021-09-27 15:47:39 -07:00
responseData = await apiRequest . call ( this , requestMethod , endpoint , { } , qs , { formData } ) ;
} else {
responseData = await apiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
}
2019-10-04 03:35:06 -07:00
2021-07-19 23:58:54 -07:00
if ( resource === 'file' && operation === 'get' ) {
2022-12-02 12:54:28 -08:00
if ( this . getNodeParameter ( 'download' , i , false ) ) {
2021-07-19 23:58:54 -07:00
const filePath = responseData . result . file_path ;
2019-10-04 03:35:06 -07:00
2021-08-20 09:57:30 -07:00
const credentials = await this . getCredentials ( 'telegramApi' ) ;
2022-08-17 08:50:24 -07:00
const file = await apiRequest . call (
this ,
'GET' ,
'' ,
{ } ,
{ } ,
{
json : false ,
encoding : null ,
uri : ` https://api.telegram.org/file/bot ${ credentials . accessToken } / ${ filePath } ` ,
resolveWithFullResponse : true ,
2023-01-27 01:30:10 -08:00
useStream : true ,
2022-08-17 08:50:24 -07:00
} ,
) ;
2020-12-29 04:28:50 -08:00
2021-07-19 23:58:54 -07:00
const fileName = filePath . split ( '/' ) . pop ( ) ;
2023-02-27 19:39:43 -08:00
const data = await this . helpers . prepareBinaryData (
file . body as Buffer ,
fileName as string ,
) ;
2020-12-29 04:28:50 -08:00
2021-07-19 23:58:54 -07:00
returnData . push ( {
json : responseData ,
2023-01-27 01:30:10 -08:00
binary : { data } ,
2022-08-30 08:55:33 -07:00
pairedItem : { item : i } ,
2021-07-19 23:58:54 -07:00
} ) ;
continue ;
2020-12-29 04:28:50 -08:00
}
2022-05-02 01:00:29 -07:00
} else if ( resource === 'chat' && operation === 'administrators' ) {
2022-08-30 08:55:33 -07:00
const executionData = this . helpers . constructExecutionMetaData (
2023-02-27 19:39:43 -08:00
this . helpers . returnJsonArray ( responseData . result as IDataObject [ ] ) ,
2022-08-30 08:55:33 -07:00
{ itemData : { item : i } } ,
) ;
returnData . push ( . . . executionData ) ;
2022-05-02 01:00:29 -07:00
continue ;
2021-07-19 23:58:54 -07:00
}
2020-12-29 04:28:50 -08:00
2022-08-30 08:55:33 -07:00
const executionData = this . helpers . constructExecutionMetaData (
2023-02-27 19:39:43 -08:00
this . helpers . returnJsonArray ( responseData as IDataObject [ ] ) ,
2022-08-30 08:55:33 -07:00
{ itemData : { item : i } } ,
) ;
returnData . push ( . . . executionData ) ;
2021-07-19 23:58:54 -07:00
} catch ( error ) {
if ( this . continueOnFail ( ) ) {
2022-11-18 05:31:38 -08:00
returnData . push ( { json : { } , error : error.message } ) ;
2020-12-29 04:28:50 -08:00
continue ;
}
2021-07-19 23:58:54 -07:00
throw error ;
2020-12-29 04:28:50 -08:00
}
2019-10-04 03:35:06 -07:00
}
2023-09-05 03:59:02 -07:00
return [ returnData ] ;
2019-10-04 03:35:06 -07:00
}
}