mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
sendMessageAction operation supports topics in supergroups
This commit is contained in:
parent
f003d939fc
commit
57a903cd5b
|
@ -118,68 +118,68 @@ export function addAdditionalFields(
|
||||||
|
|
||||||
Object.assign(body, additionalFields);
|
Object.assign(body, additionalFields);
|
||||||
|
|
||||||
// Add the reply markup
|
if (operation !== 'sendMediaGroup' && operation !== 'sendChatAction') {
|
||||||
let replyMarkupOption = '';
|
// Add the reply markup
|
||||||
if (operation !== 'sendMediaGroup') {
|
let replyMarkupOption = '';
|
||||||
replyMarkupOption = this.getNodeParameter('replyMarkup', index) as string;
|
replyMarkupOption = this.getNodeParameter('replyMarkup', index) as string;
|
||||||
if (replyMarkupOption === 'none') {
|
if (replyMarkupOption === 'none') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
body.reply_markup = {} as
|
body.reply_markup = {} as
|
||||||
| IMarkupForceReply
|
| IMarkupForceReply
|
||||||
| IMarkupReplyKeyboardRemove
|
| IMarkupReplyKeyboardRemove
|
||||||
| ITelegramInlineReply
|
| ITelegramInlineReply
|
||||||
| ITelegramReplyKeyboard;
|
| ITelegramReplyKeyboard;
|
||||||
if (['inlineKeyboard', 'replyKeyboard'].includes(replyMarkupOption)) {
|
if (['inlineKeyboard', 'replyKeyboard'].includes(replyMarkupOption)) {
|
||||||
let setParameterName = 'inline_keyboard';
|
let setParameterName = 'inline_keyboard';
|
||||||
if (replyMarkupOption === 'replyKeyboard') {
|
if (replyMarkupOption === 'replyKeyboard') {
|
||||||
setParameterName = 'keyboard';
|
setParameterName = 'keyboard';
|
||||||
}
|
|
||||||
|
|
||||||
const keyboardData = this.getNodeParameter(replyMarkupOption, index) as IMarkupKeyboard;
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
(body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] =
|
|
||||||
[] as ITelegramKeyboardButton[][];
|
|
||||||
let sendButtonData: ITelegramKeyboardButton;
|
|
||||||
if (keyboardData.rows !== undefined) {
|
|
||||||
for (const row of keyboardData.rows) {
|
|
||||||
const sendRows: ITelegramKeyboardButton[] = [];
|
|
||||||
if (row.row?.buttons === undefined) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const button of row.row.buttons) {
|
|
||||||
sendButtonData = {};
|
|
||||||
sendButtonData.text = button.text;
|
|
||||||
if (button.additionalFields) {
|
|
||||||
Object.assign(sendButtonData, button.additionalFields);
|
|
||||||
}
|
|
||||||
sendRows.push(sendButtonData);
|
|
||||||
}
|
|
||||||
// @ts-ignore
|
|
||||||
// prettier-ignore
|
|
||||||
((body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] as ITelegramKeyboardButton[][]).push(sendRows);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (replyMarkupOption === 'forceReply') {
|
|
||||||
const forceReply = this.getNodeParameter('forceReply', index) as IMarkupForceReply;
|
|
||||||
body.reply_markup = forceReply;
|
|
||||||
} else if (replyMarkupOption === 'replyKeyboardRemove') {
|
|
||||||
const forceReply = this.getNodeParameter(
|
|
||||||
'replyKeyboardRemove',
|
|
||||||
index,
|
|
||||||
) as IMarkupReplyKeyboardRemove;
|
|
||||||
body.reply_markup = forceReply;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (replyMarkupOption === 'replyKeyboard') {
|
const keyboardData = this.getNodeParameter(replyMarkupOption, index) as IMarkupKeyboard;
|
||||||
const replyKeyboardOptions = this.getNodeParameter(
|
|
||||||
'replyKeyboardOptions',
|
// @ts-ignore
|
||||||
index,
|
(body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] =
|
||||||
) as IMarkupReplyKeyboardOptions;
|
[] as ITelegramKeyboardButton[][];
|
||||||
Object.assign(body.reply_markup, replyKeyboardOptions);
|
let sendButtonData: ITelegramKeyboardButton;
|
||||||
|
if (keyboardData.rows !== undefined) {
|
||||||
|
for (const row of keyboardData.rows) {
|
||||||
|
const sendRows: ITelegramKeyboardButton[] = [];
|
||||||
|
if (row.row?.buttons === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const button of row.row.buttons) {
|
||||||
|
sendButtonData = {};
|
||||||
|
sendButtonData.text = button.text;
|
||||||
|
if (button.additionalFields) {
|
||||||
|
Object.assign(sendButtonData, button.additionalFields);
|
||||||
|
}
|
||||||
|
sendRows.push(sendButtonData);
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
// prettier-ignore
|
||||||
|
((body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] as ITelegramKeyboardButton[][]).push(sendRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (replyMarkupOption === 'forceReply') {
|
||||||
|
const forceReply = this.getNodeParameter('forceReply', index) as IMarkupForceReply;
|
||||||
|
body.reply_markup = forceReply;
|
||||||
|
} else if (replyMarkupOption === 'replyKeyboardRemove') {
|
||||||
|
const forceReply = this.getNodeParameter(
|
||||||
|
'replyKeyboardRemove',
|
||||||
|
index,
|
||||||
|
) as IMarkupReplyKeyboardRemove;
|
||||||
|
body.reply_markup = forceReply;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (replyMarkupOption === 'replyKeyboard') {
|
||||||
|
const replyKeyboardOptions = this.getNodeParameter(
|
||||||
|
'replyKeyboardOptions',
|
||||||
|
index,
|
||||||
|
) as IMarkupReplyKeyboardOptions;
|
||||||
|
Object.assign(body.reply_markup, replyKeyboardOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1454,6 +1454,7 @@ export class Telegram implements INodeType {
|
||||||
'editMessageText',
|
'editMessageText',
|
||||||
'sendAnimation',
|
'sendAnimation',
|
||||||
'sendAudio',
|
'sendAudio',
|
||||||
|
'sendChatAction',
|
||||||
'sendDocument',
|
'sendDocument',
|
||||||
'sendLocation',
|
'sendLocation',
|
||||||
'sendMessage',
|
'sendMessage',
|
||||||
|
@ -1506,7 +1507,7 @@ export class Telegram implements INodeType {
|
||||||
default: false,
|
default: false,
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
hide: {
|
hide: {
|
||||||
'/operation': ['editMessageText'],
|
'/operation': ['editMessageText', 'sendChatAction'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
|
@ -1627,7 +1628,7 @@ export class Telegram implements INodeType {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
hide: {
|
hide: {
|
||||||
'/operation': ['editMessageText'],
|
'/operation': ['editMessageText', 'sendChatAction'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: 0,
|
default: 0,
|
||||||
|
@ -1908,8 +1909,8 @@ export class Telegram implements INodeType {
|
||||||
|
|
||||||
body.chat_id = this.getNodeParameter('chatId', i) as string;
|
body.chat_id = this.getNodeParameter('chatId', i) as string;
|
||||||
body.action = this.getNodeParameter('action', i) as string;
|
body.action = this.getNodeParameter('action', i) as string;
|
||||||
|
|
||||||
// Add additional fields (topic id)
|
// Add additional fields
|
||||||
addAdditionalFields.call(this, body, i);
|
addAdditionalFields.call(this, body, i);
|
||||||
} else if (operation === 'sendDocument') {
|
} else if (operation === 'sendDocument') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
Loading…
Reference in a new issue