Skip to content

Commit

Permalink
fixed #380
Browse files Browse the repository at this point in the history
  • Loading branch information
windka committed Jun 21, 2024
1 parent aecc5bd commit 13ae259
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

# [15.1.11] - 2024-06-14
### added option for enabling test environment - [#380](https://github.com/windkh/node-red-contrib-telegrambot/issues/380)

# [15.1.9] - 2024-01-30
### Added full weblink in response message of getfile.
- see also - [#357](https://github.com/windkh/node-red-contrib-telegrambot/pull/357)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ This is the server url of the telegram server (https://api.telegram.org). If you
Typically this field is left blank.


### Configuration property *Test Environment*
This enables the test environment see: (https://core.telegram.org/bots/features#testing-your-bot).

Typically this checkbox is unchecked.


### Configuration property *Update Mode*
The update mode can be chosen from *Polling* or *Webhook*.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-telegrambot",
"version": "15.1.10",
"version": "15.1.11",
"description": "Telegram bot nodes for Node-RED",
"dependencies": {
"bluebird": "^3.7.2",
Expand Down
7 changes: 6 additions & 1 deletion telegrambot/99-telegrambot.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
usernames: { value: "", required: false },
chatids: { value: "", required: false },
baseapiurl: { value: "", required: false },
testenvironment: { value: false, required: false },

updatemode: { value: "polling", required: true },

Expand Down Expand Up @@ -117,10 +118,14 @@
<input type="text" id="node-config-input-chatids" placeholder="(Optional list of authorized chat-ids e.g.: -1234567,2345678,-3456789)">
</div>
<div class="form-row">
<label for="node-config-input-baseapiurl"><i class="fa fa-server"></i> Server URL</label>
<label for="node-config-input-baseapiurl"><i class="fa fa-send"></i> Server URL</label>
<input type="text" id="node-config-input-baseapiurl" placeholder="(Optional URL for proxying and testing e.g.: https://api.telegram.org)">
</div>

<label for="node-config-input-testenvironment"><i class="fa fa-server"></i> Test Environment</label>
<input type="checkbox" id="node-config-input-testenvironment" style="display: inline-block; width: auto; vertical-align: top;">
</div>

<div class="form-row">
<label for="node-config-input-updatemode"><i class="fa fa-link"></i> Update Mode</label>
<select id="node-config-input-updatemode">
Expand Down
17 changes: 6 additions & 11 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ module.exports = function (RED) {
this.verbose = n.verboselogging;

this.baseApiUrl = n.baseapiurl;
this.testEnvironment = n.testenvironment;

this.updateMode = n.updatemode;
if (!this.updateMode) {
Expand Down Expand Up @@ -269,6 +270,7 @@ module.exports = function (RED) {
const options = {
webHook: webHook,
baseApiUrl: this.baseApiUrl,
testEnvironment: this.testEnvironment,
request: this.socksRequest,
};

Expand Down Expand Up @@ -375,6 +377,7 @@ module.exports = function (RED) {
const options = {
polling: polling,
baseApiUrl: this.baseApiUrl,
testEnvironment: this.testEnvironment,
request: this.socksRequest,
};
newTelegramBot = new telegramBotEx(this.token, options);
Expand Down Expand Up @@ -443,6 +446,7 @@ module.exports = function (RED) {

const options = {
baseApiUrl: this.baseApiUrl,
testEnvironment: this.testEnvironment,
request: this.socksRequest,
};
newTelegramBot = new telegramBotEx(this.token, options);
Expand Down Expand Up @@ -2171,23 +2175,15 @@ module.exports = function (RED) {
node.processResult(result, msg, nodeSend, nodeDone);
});
} else if (msg.payload.getfile) {
let fileId = msg.payload.getfile.fileId;
let fileId = msg.payload.getFile.fileId;

telegramBot
.getFile(fileId)
.catch(function (ex) {
node.processError(ex, msg, nodeSend, nodeDone);
})
.then(function (result) {
telegramBot
.getFileLink(fileId)
.catch(function (ex) {
node.processError(ex, msg, nodeSend, nodeDone);
})
.then(function (weblink) {
msg.weblink = weblink;
node.processResult(result, msg, nodeSend, nodeDone);
});
node.processResult(result, msg, nodeSend, nodeDone);
});
} else {
if (msg.payload.type) {
Expand Down Expand Up @@ -2642,7 +2638,6 @@ module.exports = function (RED) {
case 'getChatMember':
case 'approveChatJoinRequest':
case 'declineChatJoinRequest':
case 'setChatAdministratorCustomTitle':
case 'stopPoll':
// The userId must be passed in msg.payload.content: note that this is is a number not the username.
// Right now there is no way for resolving the user_id by username in the official API.
Expand Down

0 comments on commit 13ae259

Please sign in to comment.