@patricktobias86/node-red-telegram-account 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -2,3 +2,4 @@
2
2
 
3
3
  - Always run `npm test` before creating a commit.
4
4
  - If a code change alters user-facing behavior, update the README and any relevant docs to reflect the change.
5
+ - Bump version for any code change
package/CHANGELOG.md CHANGED
@@ -13,3 +13,9 @@ All notable changes to this project will be documented in this file.
13
13
  ### Fixed
14
14
  - Receiver and Command nodes now remove their event listeners when closed to prevent duplicate messages after redeploys.
15
15
 
16
+ ## [1.1.10] - 2025-07-27
17
+ ### Fixed
18
+ - Receiver node no longer fails when Debug is enabled and handles updates containing `BigInt` values.
19
+ ### Changed
20
+ - `delete-message` now forwards the original message along with the Telegram API response.
21
+
package/README.md CHANGED
@@ -23,7 +23,7 @@ See [docs/NODES.md](docs/NODES.md) for a detailed description of every node. Bel
23
23
  - **send-message** – sends text or media messages with rich options.
24
24
  - **send-files** – uploads one or more files with captions and buttons.
25
25
  - **get-entity** – resolves usernames, IDs or t.me links into Telegram entities.
26
- - **delete-message** – deletes one or more messages, optionally revoking them.
26
+ - **delete-message** – deletes one or more messages, optionally revoking them, and forwards the original input message with the API response.
27
27
  - **iter-dialogs** – iterates over your dialogs (chats, groups, channels).
28
28
  - **iter-messages** – iterates over messages in a chat with filtering options.
29
29
  - **promote-admin** – promotes a user to admin with configurable rights.
package/docs/NODES.md CHANGED
@@ -13,7 +13,7 @@ Below is a short description of each node. For a full list of configuration opti
13
13
  | **send-message** | Sends text messages or media files to a chat. Supports parse mode, buttons, scheduling, and more. |
14
14
  | **send-files** | Uploads one or more files to a chat with optional caption, thumbnails and other parameters. |
15
15
  | **get-entity** | Resolves a username, user ID or t.me URL into a Telegram entity object. |
16
- | **delete-message** | Deletes one or multiple messages from a chat. Can revoke messages for all participants. |
16
+ | **delete-message** | Deletes one or multiple messages from a chat while passing the original input message along with the API response. Can revoke messages for all participants. |
17
17
  | **iter-dialogs** | Iterates through the user’s dialogs (chats, groups, channels) and outputs the collected list. |
18
18
  | **iter-messages** | Iterates over messages in a chat with various filtering and pagination options. |
19
19
  | **promote-admin** | Grants admin rights to a user in a group or channel with configurable permissions. |
@@ -82,7 +82,7 @@
82
82
  <dt>payload
83
83
  <span class="property-type">object</span>
84
84
  </dt>
85
- <dd>The response from the Telegram API, confirming the deletion.</dd>
85
+ <dd>The response from the Telegram API, confirming the deletion. All other properties from the input message are preserved.</dd>
86
86
  </dl>
87
87
 
88
88
  <h3>Details</h3>
@@ -1,3 +1,5 @@
1
+ const util = require("util");
2
+
1
3
  module.exports = function (RED) {
2
4
  function DeleteMessage(config) {
3
5
  RED.nodes.createNode(this, config);
@@ -8,21 +10,21 @@ module.exports = function (RED) {
8
10
  this.on('input', async function (msg) {
9
11
  const debug = node.debugEnabled || msg.debug;
10
12
  if (debug) {
11
- node.log('delete-message input: ' + JSON.stringify(msg));
13
+ node.log('delete-message input: ' + util.inspect(msg, { depth: null }));
12
14
  }
13
15
  const chatId = msg.payload.chatId || config.chatId;
14
16
  const messageIds = msg.payload.messageIds || config.messageIds;
15
- const revoke = msg.payload.revoke || config.revoke || { revoke: true };
17
+ const revoke = msg.payload.revoke ?? config.revoke ?? true;
16
18
  /** @type {TelegramClient} */
17
19
  const client = msg.payload?.client ? msg.payload.client : this.config.client;
18
20
 
19
21
  try {
20
- const response = await client.deleteMessages(chatId, messageIds, revoke);
22
+ const response = await client.deleteMessages(chatId, messageIds, { revoke });
21
23
 
22
- const out = { payload: response };
24
+ const out = { ...msg, payload: response };
23
25
  node.send(out);
24
26
  if (debug) {
25
- node.log('delete-message output: ' + JSON.stringify(out));
27
+ node.log('delete-message output: ' + util.inspect(out, { depth: null }));
26
28
  }
27
29
  } catch (err) {
28
30
  node.error('Error deleting message: ' + err.message);
package/nodes/receiver.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const { NewMessage } = require("telegram/events");
2
+ const util = require("util");
2
3
 
3
4
  module.exports = function (RED) {
4
5
  function Receiver(config) {
@@ -13,13 +14,13 @@ module.exports = function (RED) {
13
14
  const handler = (update) => {
14
15
  const debug = node.debugEnabled;
15
16
  if (debug) {
16
- node.log('receiver update: ' + JSON.stringify(update));
17
+ node.log('receiver update: ' + util.inspect(update, { depth: null }));
17
18
  }
18
19
  if (update.message.fromId != null && !ignore.includes(update.message.fromId.userId.toString())) {
19
20
  const out = { payload: { update } };
20
21
  node.send(out);
21
22
  if (debug) {
22
- node.log('receiver output: ' + JSON.stringify(out));
23
+ node.log('receiver output: ' + util.inspect(out, { depth: null }));
23
24
  }
24
25
  }
25
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patricktobias86/node-red-telegram-account",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "Node-RED nodes to communicate with GramJS.",
5
5
  "main": "nodes/config.js",
6
6
  "keywords": [
@@ -0,0 +1,44 @@
1
+ const assert = require('assert');
2
+ const proxyquire = require('proxyquire').noPreserveCache();
3
+
4
+ function load() {
5
+ const addCalls = [];
6
+ const logs = [];
7
+ class TelegramClientStub {
8
+ addEventHandler(fn, event) { addCalls.push({fn, event}); }
9
+ removeEventHandler() {}
10
+ }
11
+ class NewMessageStub {}
12
+
13
+ let NodeCtor;
14
+ const configNode = { client: new TelegramClientStub() };
15
+ const RED = {
16
+ nodes: {
17
+ createNode(node) {
18
+ node._events = {};
19
+ node.on = (e, fn) => { node._events[e] = fn; };
20
+ node.log = (msg) => logs.push(msg);
21
+ node.send = () => {};
22
+ },
23
+ registerType(name, ctor) { NodeCtor = ctor; },
24
+ getNode() { return configNode; }
25
+ }
26
+ };
27
+
28
+ proxyquire('../nodes/receiver.js', {
29
+ 'telegram/events': { NewMessage: NewMessageStub }
30
+ })(RED);
31
+
32
+ return { NodeCtor, addCalls, logs };
33
+ }
34
+
35
+ describe('Receiver node debug with BigInt', function() {
36
+ it('logs update and output without throwing', function() {
37
+ const { NodeCtor, addCalls, logs } = load();
38
+ const node = new NodeCtor({config:'c', ignore:'', debug:true});
39
+ const handler = addCalls[0].fn;
40
+ assert.doesNotThrow(() => handler({ message: { fromId:{userId:1n} } }));
41
+ assert(logs.some(l => l.includes('receiver update')));
42
+ assert(logs.some(l => l.includes('receiver output')));
43
+ });
44
+ });