feat(Telegram Node): Add support for local bot api server (#8437)
Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
This commit is contained in:
@@ -26,10 +26,17 @@ export const credentialTypeTelegram = {
|
|||||||
description:
|
description:
|
||||||
'Chat with the <a href="https://telegram.me/botfather">bot father</a> to obtain the access token',
|
'Chat with the <a href="https://telegram.me/botfather">bot father</a> to obtain the access token',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Base URL',
|
||||||
|
name: 'baseUrl',
|
||||||
|
type: 'string',
|
||||||
|
default: 'https://api.telegram.org',
|
||||||
|
description: 'Base URL for Telegram Bot API',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
test: {
|
test: {
|
||||||
request: {
|
request: {
|
||||||
baseURL: '=https://api.telegram.org/bot{{$credentials.accessToken}}',
|
baseURL: '={{$credentials.baseUrl}}/bot{{$credentials.accessToken}}',
|
||||||
url: '/getMe',
|
url: '/getMe',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,11 +17,18 @@ export class TelegramApi implements ICredentialType {
|
|||||||
description:
|
description:
|
||||||
'Chat with the <a href="https://telegram.me/botfather">bot father</a> to obtain the access token',
|
'Chat with the <a href="https://telegram.me/botfather">bot father</a> to obtain the access token',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Base URL',
|
||||||
|
name: 'baseUrl',
|
||||||
|
type: 'string',
|
||||||
|
default: 'https://api.telegram.org',
|
||||||
|
description: 'Base URL for Telegram Bot API',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
test: ICredentialTestRequest = {
|
test: ICredentialTestRequest = {
|
||||||
request: {
|
request: {
|
||||||
baseURL: '=https://api.telegram.org/bot{{$credentials.accessToken}}',
|
baseURL: '={{$credentials.baseUrl}}/bot{{$credentials.accessToken}}',
|
||||||
url: '/getMe',
|
url: '/getMe',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ export async function apiRequest(
|
|||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {},
|
headers: {},
|
||||||
method,
|
method,
|
||||||
uri: `https://api.telegram.org/bot${credentials.accessToken}/${endpoint}`,
|
uri: `${credentials.baseUrl}/bot${credentials.accessToken}/${endpoint}`,
|
||||||
body,
|
body,
|
||||||
qs: query,
|
qs: query,
|
||||||
json: true,
|
json: true,
|
||||||
|
|||||||
@@ -2067,7 +2067,7 @@ export class Telegram implements INodeType {
|
|||||||
{
|
{
|
||||||
json: false,
|
json: false,
|
||||||
encoding: null,
|
encoding: null,
|
||||||
uri: `https://api.telegram.org/file/bot${credentials.accessToken}/${filePath}`,
|
uri: `${credentials.baseUrl}/bot${credentials.accessToken}/${filePath}`,
|
||||||
resolveWithFullResponse: true,
|
resolveWithFullResponse: true,
|
||||||
useStream: true,
|
useStream: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ export class TelegramTrigger implements INodeType {
|
|||||||
{
|
{
|
||||||
json: false,
|
json: false,
|
||||||
encoding: null,
|
encoding: null,
|
||||||
uri: `https://api.telegram.org/file/bot${credentials.accessToken}/${file_path}`,
|
uri: `${credentials.baseUrl}/file/bot${credentials.accessToken}/${file_path}`,
|
||||||
resolveWithFullResponse: true,
|
resolveWithFullResponse: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user