Add answerinlinequery option to Telegram (#1556)

* telegram node: add answerinlinequery option

* remove comments
This commit is contained in:
Pavel Yudin 2021-03-24 20:51:00 +03:00 committed by GitHub
parent 68c14979d3
commit 0d8602de5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -156,11 +156,15 @@ export class Telegram implements INodeType {
value: 'answerQuery',
description: 'Send answer to callback query sent from inline keyboard.',
},
{
name: 'Answer Inline Query',
value: 'answerInlineQuery',
description: 'Send answer to callback query sent from inline bot.',
},
],
default: 'answerQuery',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
@ -508,13 +512,104 @@ export class Telegram implements INodeType {
],
},
// -----------------------------------------------
// callback:answerInlineQuery
// -----------------------------------------------
{
displayName: 'Query ID',
name: 'queryId',
type: 'string',
default: '',
displayOptions: {
show: {
operation: [
'answerInlineQuery',
],
resource: [
'callback',
],
},
},
required: true,
description: 'Unique identifier for the answered query.',
},
{
displayName: 'Results',
name: 'results',
type: 'string',
default: '',
displayOptions: {
show: {
operation: [
'answerInlineQuery',
],
resource: [
'callback',
],
},
},
required: true,
description: 'A JSON-serialized array of results for the inline query.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'answerInlineQuery',
],
resource: [
'callback',
],
},
},
default: {},
options: [
{
displayName: 'Cache Time',
name: 'cache_time',
type: 'number',
typeOptions: {
minValue: 0,
},
default: 0,
description: 'The maximum amount of time in seconds that the result of the callback query may be cached client-side.',
},
{
displayName: 'Show Alert',
name: 'show_alert',
type: 'boolean',
default: false,
description: 'If true, an alert will be shown by the client instead of a notification at the top of the chat screen.',
},
{
displayName: 'Text',
name: 'text',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: 'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.',
},
{
displayName: 'URL',
name: 'url',
type: 'string',
default: '',
description: 'URL that will be opened by the user\'s client.',
},
],
},
// ----------------------------------
// file
// ----------------------------------
// ----------------------------------
// file:get/download
// ----------------------------------
@ -1649,7 +1744,21 @@ export class Telegram implements INodeType {
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields);
} else if (operation === 'answerInlineQuery') {
// -----------------------------------------------
// callback:answerInlineQuery
// -----------------------------------------------
endpoint = 'answerInlineQuery';
body.inline_query_id = this.getNodeParameter('queryId', i) as string;
body.results = this.getNodeParameter('results', i) as string;
// Add additional fields
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields);
}
} else if (resource === 'chat') {
if (operation === 'get') {
// ----------------------------------