@patricktobias86/node-red-telegram-account 1.1.21 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.2.0] - 2026-01-12
6
+ ### Changed
7
+ - Switched underlying Telegram MTProto client dependency from `telegram` (GramJS) to `teleproto`.
8
+
9
+ ## [1.1.22] - 2026-01-12
10
+ ### Fixed
11
+ - Receiver node now handles additional MTProto update types that were being silently dropped:
12
+ - `UpdateNewScheduledMessage` - Scheduled messages
13
+ - `UpdateDeleteScheduledMessages` - Deleted scheduled messages
14
+ - `UpdateBotNewBusinessMessage` - Telegram Business account messages
15
+ - `UpdateBotEditBusinessMessage` - Edited business messages
16
+ - `UpdateBotDeleteBusinessMessage` - Deleted business messages
17
+ - `UpdateQuickReplyMessage` - Quick reply messages
18
+ - `UpdateReadStories` - Story read updates
19
+
5
20
  ## [1.1.21] - 2026-01-06
6
21
  ### Fixed
7
22
  - Receiver node now correctly handles messages from channels when the sender is an anonymous admin, ensuring such messages are processed and not dropped.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Node-RED nodes to communicate with GramJS
1
+ # Node-RED nodes to communicate with TeleProto
2
2
 
3
3
  <p align="center">
4
4
  <img alt="GitHub issues" src="https://img.shields.io/github/issues/patricktobias86/node-red-telegram-account?color=56BEB8" />
@@ -10,7 +10,7 @@
10
10
  npm i @patricktobias86/node-red-telegram-account
11
11
  ```
12
12
 
13
- This package contains a collection of Node‑RED nodes built on top of [GramJS](https://gram.js.org/). They make it easier to interact with the Telegram MTProto API from your flows.
13
+ This package contains a collection of Node‑RED nodes built on top of [TeleProto](https://www.npmjs.com/package/teleproto). They make it easier to interact with the Telegram MTProto API from your flows.
14
14
 
15
15
  ## Node overview
16
16
 
package/docs/NODES.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Node Overview
2
2
 
3
- The package provides a set of custom Node-RED nodes built around the [GramJS](https://gram.js.org/) library. Each node exposes a small part of the Telegram API, making it easier to build Telegram bots and automation flows.
3
+ The package provides a set of custom Node-RED nodes built around the [TeleProto](https://www.npmjs.com/package/teleproto) library. Each node exposes a small part of the Telegram API, making it easier to build Telegram bots and automation flows.
4
4
 
5
5
  Below is a short description of each node. For a full list of configuration options see the built‑in help inside Node‑RED or open the corresponding HTML files in the `nodes/` directory.
6
6
 
package/nodes/auth.html CHANGED
@@ -84,7 +84,7 @@
84
84
  </script>
85
85
 
86
86
  <script type="text/html" data-help-name="auth">
87
- <p>The <b>auth</b> node facilitates Telegram API authentication using the <code>telegram</code> (GramJS) library. It allows users to authenticate a session and retrieve a <code>stringSession</code> for reuse with other Telegram clients.</p>
87
+ <p>The <b>auth</b> node facilitates Telegram API authentication using the <code>teleproto</code> library. It allows users to authenticate a session and retrieve a <code>stringSession</code> for reuse with other Telegram clients.</p>
88
88
  <p>Enable <b>Debug</b> to log the incoming credentials and returned session.</p>
89
89
 
90
90
  <h3>Inputs</h3>
package/nodes/auth.js CHANGED
@@ -1,5 +1,5 @@
1
- const { TelegramClient } = require("telegram");
2
- const { StringSession } = require("telegram/sessions");
1
+ const { TelegramClient } = require("teleproto");
2
+ const { StringSession } = require("teleproto/sessions");
3
3
 
4
4
  module.exports = function (RED) {
5
5
  function TelegramClientConfig(config) {
package/nodes/command.js CHANGED
@@ -1,4 +1,4 @@
1
- const { NewMessage } = require("telegram/events");
1
+ const { NewMessage } = require("teleproto/events");
2
2
 
3
3
 
4
4
  module.exports = function (RED) {
package/nodes/config.js CHANGED
@@ -1,5 +1,5 @@
1
- const { TelegramClient } = require("telegram");
2
- const { StringSession } = require("telegram/sessions");
1
+ const { TelegramClient } = require("teleproto");
2
+ const { StringSession } = require("teleproto/sessions");
3
3
 
4
4
  const activeClients = new Map(); // Cache: session string → { client, refCount, connecting }
5
5
 
@@ -1,4 +1,4 @@
1
- const { TelegramClient } = require("telegram");
1
+ const { TelegramClient } = require("teleproto");
2
2
 
3
3
  module.exports = function (RED) {
4
4
  function IterDialogs(config) {
@@ -1,4 +1,4 @@
1
- const { TelegramClient, utils, Api } = require("telegram");
1
+ const { TelegramClient, utils, Api } = require("teleproto");
2
2
 
3
3
  module.exports = function (RED) {
4
4
  function IterMessages(config) {
@@ -197,7 +197,7 @@
197
197
 
198
198
  </script>
199
199
  <script type="text/html" data-help-name="promote-admin">
200
- <p><b>Promote Admin</b> lets you promote a user to admin in a Telegram group or channel using the Telegram MTProto API (via GramJS).</p>
200
+ <p><b>Promote Admin</b> lets you promote a user to admin in a Telegram group or channel using the Telegram MTProto API (via TeleProto).</p>
201
201
  <p>With <b>Debug</b> enabled the node logs its request and the response from Telegram.</p>
202
202
 
203
203
  <h3>Inputs</h3>
@@ -249,4 +249,4 @@
249
249
  }
250
250
  }
251
251
  </pre>
252
- </script>
252
+ </script>
@@ -1,6 +1,6 @@
1
- const { TelegramClient } = require("telegram");
2
- const { parseID } = require("telegram/Utils");
3
- const { Api } = require("telegram");
1
+ const { TelegramClient } = require("teleproto");
2
+ const { parseID } = require("teleproto/Utils");
3
+ const { Api } = require("teleproto");
4
4
 
5
5
  module.exports = function (RED) {
6
6
  function PromoteAdmin(config) {
@@ -56,4 +56,4 @@ module.exports = function (RED) {
56
56
  }
57
57
 
58
58
  RED.nodes.registerType("promote-admin", PromoteAdmin);
59
- };
59
+ };
package/nodes/receiver.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Raw } = require("telegram/events");
1
+ const { Raw } = require("teleproto/events");
2
2
  const util = require("util");
3
3
 
4
4
  const splitList = (value) => {
@@ -321,10 +321,23 @@ const extractMessageEvents = (rawUpdate) => {
321
321
  return;
322
322
  }
323
323
 
324
+ // Handle all known message-bearing update types.
325
+ // Standard message updates:
324
326
  if (className === 'UpdateNewMessage' ||
325
327
  className === 'UpdateNewChannelMessage' ||
326
328
  className === 'UpdateEditMessage' ||
327
- className === 'UpdateEditChannelMessage') {
329
+ className === 'UpdateEditChannelMessage' ||
330
+ // Scheduled message updates:
331
+ className === 'UpdateNewScheduledMessage' ||
332
+ className === 'UpdateDeleteScheduledMessages' ||
333
+ // Business account message updates (Telegram Business API):
334
+ className === 'UpdateBotNewBusinessMessage' ||
335
+ className === 'UpdateBotEditBusinessMessage' ||
336
+ className === 'UpdateBotDeleteBusinessMessage' ||
337
+ // Quick reply message updates:
338
+ className === 'UpdateQuickReplyMessage' ||
339
+ // Read stories (contains message-like content):
340
+ className === 'UpdateReadStories') {
328
341
  if (update.message) {
329
342
  results.push({ update, message: update.message });
330
343
  } else {
@@ -220,7 +220,7 @@
220
220
  </script>
221
221
 
222
222
  <script type="text/html" data-help-name="send-message">
223
- <p>The <b>send-message</b> node allows sending messages via Telegram using the <code>telegram</code> library. It supports various message types, formatting options, and additional features like scheduling and silent messages.</p>
223
+ <p>The <b>send-message</b> node allows sending messages via Telegram using the <code>teleproto</code> library. It supports various message types, formatting options, and additional features like scheduling and silent messages.</p>
224
224
  <p>Enable the <b>Debug</b> option to log incoming and outgoing messages to the Node-RED log.</p>
225
225
 
226
226
  <h3>Inputs</h3>
@@ -1,5 +1,5 @@
1
- const { TelegramClient } = require("telegram");
2
- const { parseID } = require("telegram/Utils");
1
+ const { TelegramClient } = require("teleproto");
2
+ const { parseID } = require("teleproto/Utils");
3
3
 
4
4
  module.exports = function (RED) {
5
5
  function SendMessage(config) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@patricktobias86/node-red-telegram-account",
3
- "version": "1.1.21",
4
- "description": "Node-RED nodes to communicate with GramJS.",
3
+ "version": "1.2.0",
4
+ "description": "Node-RED nodes to communicate with TeleProto.",
5
5
  "main": "nodes/config.js",
6
6
  "keywords": [
7
7
  "node-red",
@@ -44,7 +44,7 @@
44
44
  "registry": "https://registry.npmjs.org"
45
45
  },
46
46
  "dependencies": {
47
- "telegram": "^2.17.10"
47
+ "teleproto": "^1.221.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "mocha": "^11.7.1",
Binary file
package/test/auth.test.js CHANGED
@@ -29,8 +29,8 @@ function setup() {
29
29
  };
30
30
 
31
31
  proxyquire('../nodes/auth.js', {
32
- telegram: { TelegramClient: TelegramClientStub },
33
- 'telegram/sessions': { StringSession: StringSessionStub }
32
+ teleproto: { TelegramClient: TelegramClientStub },
33
+ 'teleproto/sessions': { StringSession: StringSessionStub }
34
34
  })(RED);
35
35
 
36
36
  return { NodeCtor, getSent: () => sent };
@@ -24,7 +24,7 @@ function load() {
24
24
  };
25
25
 
26
26
  proxyquire('../nodes/command.js', {
27
- 'telegram/events': { NewMessage: NewMessageStub }
27
+ 'teleproto/events': { NewMessage: NewMessageStub }
28
28
  })(RED);
29
29
 
30
30
  return { NodeCtor, addCalls, removeCalls };
@@ -32,8 +32,8 @@ function load() {
32
32
  };
33
33
 
34
34
  proxyquire('../nodes/config.js', {
35
- telegram: { TelegramClient: TelegramClientStub },
36
- 'telegram/sessions': { StringSession: StringSessionStub }
35
+ teleproto: { TelegramClient: TelegramClientStub },
36
+ 'teleproto/sessions': { StringSession: StringSessionStub }
37
37
  })(RED);
38
38
 
39
39
  return { NodeCtor, instances };
@@ -26,7 +26,7 @@ function load() {
26
26
  };
27
27
 
28
28
  proxyquire('../nodes/command.js', {
29
- 'telegram/events': { NewMessage: NewMessageStub }
29
+ 'teleproto/events': { NewMessage: NewMessageStub }
30
30
  })(RED);
31
31
 
32
32
  return { NodeCtor, addCalls, logs };
@@ -20,8 +20,8 @@ function setup() {
20
20
  };
21
21
 
22
22
  proxyquire('../nodes/send-message.js', {
23
- telegram: { TelegramClient: function() {} },
24
- 'telegram/Utils': { parseID: () => ({}) }
23
+ teleproto: { TelegramClient: function() {} },
24
+ 'teleproto/Utils': { parseID: () => ({}) }
25
25
  })(RED);
26
26
 
27
27
  return { NodeCtor, getSent: () => sent };
@@ -27,7 +27,7 @@ function load() {
27
27
  };
28
28
 
29
29
  proxyquire('../nodes/receiver.js', {
30
- 'telegram/events': { Raw: RawStub }
30
+ 'teleproto/events': { Raw: RawStub }
31
31
  })(RED);
32
32
 
33
33
  return { NodeCtor, addCalls, logs, sends };
@@ -24,7 +24,7 @@ function load() {
24
24
  };
25
25
 
26
26
  proxyquire('../nodes/receiver.js', {
27
- 'telegram/events': { Raw: RawStub }
27
+ 'teleproto/events': { Raw: RawStub }
28
28
  })(RED);
29
29
 
30
30
  return { NodeCtor, addCalls, removeCalls };
@@ -142,4 +142,89 @@ describe('Receiver node', function() {
142
142
  assert.strictEqual(sent[0].payload.chatId, 2877134366);
143
143
  assert.strictEqual(sent[0].payload.senderId, 6304354944);
144
144
  });
145
+
146
+ it('handles UpdateNewScheduledMessage updates', function() {
147
+ const { NodeCtor, addCalls } = load();
148
+ const sent = [];
149
+ const node = new NodeCtor({config:'c', ignore:'', ignoreMessageTypes:'', maxFileSizeMb:''});
150
+ node.send = (msg) => sent.push(msg);
151
+ const handler = addCalls[0].fn;
152
+
153
+ handler({
154
+ className: 'UpdateNewScheduledMessage',
155
+ message: {
156
+ id: 456,
157
+ fromId: { userId: 789, className: 'PeerUser' },
158
+ peerId: { userId: 789, className: 'PeerUser' },
159
+ message: 'scheduled message',
160
+ date: 1234567890
161
+ }
162
+ });
163
+
164
+ assert.strictEqual(sent.length, 1);
165
+ assert.strictEqual(sent[0].payload.message.message, 'scheduled message');
166
+ });
167
+
168
+ it('handles UpdateBotNewBusinessMessage updates', function() {
169
+ const { NodeCtor, addCalls } = load();
170
+ const sent = [];
171
+ const node = new NodeCtor({config:'c', ignore:'', ignoreMessageTypes:'', maxFileSizeMb:''});
172
+ node.send = (msg) => sent.push(msg);
173
+ const handler = addCalls[0].fn;
174
+
175
+ handler({
176
+ className: 'UpdateBotNewBusinessMessage',
177
+ message: {
178
+ id: 123,
179
+ fromId: { userId: 456, className: 'PeerUser' },
180
+ peerId: { userId: 789, className: 'PeerUser' },
181
+ message: 'business message'
182
+ }
183
+ });
184
+
185
+ assert.strictEqual(sent.length, 1);
186
+ assert.strictEqual(sent[0].payload.message.message, 'business message');
187
+ });
188
+
189
+ it('handles UpdateBotEditBusinessMessage updates', function() {
190
+ const { NodeCtor, addCalls } = load();
191
+ const sent = [];
192
+ const node = new NodeCtor({config:'c', ignore:'', ignoreMessageTypes:'', maxFileSizeMb:''});
193
+ node.send = (msg) => sent.push(msg);
194
+ const handler = addCalls[0].fn;
195
+
196
+ handler({
197
+ className: 'UpdateBotEditBusinessMessage',
198
+ message: {
199
+ id: 123,
200
+ fromId: { userId: 456, className: 'PeerUser' },
201
+ peerId: { userId: 789, className: 'PeerUser' },
202
+ message: 'edited business message'
203
+ }
204
+ });
205
+
206
+ assert.strictEqual(sent.length, 1);
207
+ assert.strictEqual(sent[0].payload.message.message, 'edited business message');
208
+ });
209
+
210
+ it('handles UpdateQuickReplyMessage updates', function() {
211
+ const { NodeCtor, addCalls } = load();
212
+ const sent = [];
213
+ const node = new NodeCtor({config:'c', ignore:'', ignoreMessageTypes:'', maxFileSizeMb:''});
214
+ node.send = (msg) => sent.push(msg);
215
+ const handler = addCalls[0].fn;
216
+
217
+ handler({
218
+ className: 'UpdateQuickReplyMessage',
219
+ message: {
220
+ id: 999,
221
+ fromId: { userId: 111, className: 'PeerUser' },
222
+ peerId: { userId: 222, className: 'PeerUser' },
223
+ message: 'quick reply'
224
+ }
225
+ });
226
+
227
+ assert.strictEqual(sent.length, 1);
228
+ assert.strictEqual(sent[0].payload.message.message, 'quick reply');
229
+ });
145
230
  });