Skip to content

Commit

Permalink
fixed #306
Browse files Browse the repository at this point in the history
  • Loading branch information
windka committed Jun 13, 2023
1 parent 2921bc1 commit 0fbc46d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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.3] - 2023-06-13
### added chat_id in options - [#306](https://github.com/windkh/node-red-contrib-telegrambot/issues/306)

# [15.1.2] - 2023-06-12
### fixed unauthorized calls in event node - [#314](https://github.com/windkh/node-red-contrib-telegrambot/issues/314)

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.2",
"version": "15.1.3",
"description": "Telegram bot nodes for Node-RED",
"dependencies": {
"bluebird": "^3.7.2",
Expand Down
11 changes: 11 additions & 0 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,14 @@ module.exports = function (RED) {
});
};

this.addChatIdToOptions = function (chatId, options) {
if (chatId !== undefined && options !== undefined) {
if (options.chat_id === undefined) {
options.chat_id = chatId;
}
}
};

this.processError = function (exception, msg, nodeSend, nodeDone) {
let errorMessage = 'Caught exception in sender node:\r\n' + exception + '\r\nwhen processing message: \r\n' + JSON.stringify(msg);

Expand Down Expand Up @@ -2440,6 +2448,7 @@ module.exports = function (RED) {

case 'editMessageLiveLocation':
if (this.hasContent(msg)) {
node.addChatIdToOptions(chatId, msg.payload.options);
telegramBot
.editMessageLiveLocation(msg.payload.content.latitude, msg.payload.content.longitude, msg.payload.options || {})
.catch(function (ex) {
Expand All @@ -2454,6 +2463,7 @@ module.exports = function (RED) {
case 'stopMessageLiveLocation':
// This message requires the options to be set!
//if (this.hasContent(msg)) {
node.addChatIdToOptions(chatId, msg.payload.options);
telegramBot
.stopMessageLiveLocation(msg.payload.options)
.catch(function (ex) {
Expand Down Expand Up @@ -2564,6 +2574,7 @@ module.exports = function (RED) {
case 'editMessageText':
case 'editMessageReplyMarkup':
if (this.hasContent(msg)) {
node.addChatIdToOptions(chatId, msg.payload.options);
telegramBot[type](msg.payload.content, msg.payload.options || {})
.catch(function (ex) {
node.processError(ex, msg, nodeSend, nodeDone);
Expand Down

0 comments on commit 0fbc46d

Please sign in to comment.