@patricktobias86/node-red-telegram-account 1.1.20 → 1.1.22
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 +15 -0
- package/nodes/receiver.html +69 -1
- package/nodes/receiver.js +26 -2
- package/package.json +1 -1
- package/test/receiver.test.js +85 -0
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.1.22] - 2026-01-12
|
|
6
|
+
### Fixed
|
|
7
|
+
- Receiver node now handles additional MTProto update types that were being silently dropped:
|
|
8
|
+
- `UpdateNewScheduledMessage` - Scheduled messages
|
|
9
|
+
- `UpdateDeleteScheduledMessages` - Deleted scheduled messages
|
|
10
|
+
- `UpdateBotNewBusinessMessage` - Telegram Business account messages
|
|
11
|
+
- `UpdateBotEditBusinessMessage` - Edited business messages
|
|
12
|
+
- `UpdateBotDeleteBusinessMessage` - Deleted business messages
|
|
13
|
+
- `UpdateQuickReplyMessage` - Quick reply messages
|
|
14
|
+
- `UpdateReadStories` - Story read updates
|
|
15
|
+
|
|
16
|
+
## [1.1.21] - 2026-01-06
|
|
17
|
+
### Fixed
|
|
18
|
+
- Receiver node now correctly handles messages from channels when the sender is an anonymous admin, ensuring such messages are processed and not dropped.
|
|
19
|
+
|
|
5
20
|
## [1.1.20] - 2026-01-05
|
|
6
21
|
### Added
|
|
7
22
|
- Receiver node now emits debug events on a second output when Debug is enabled, so you can see internal logs in the Node-RED debug sidebar.
|
package/nodes/receiver.html
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
ignore: { value:""},
|
|
10
10
|
ignoreMessageTypes: { value: "" },
|
|
11
11
|
debug: { value: false },
|
|
12
|
-
maxFileSizeMb: { value: "" }
|
|
12
|
+
maxFileSizeMb: { value: "" },
|
|
13
|
+
includeChats: { value: "" },
|
|
14
|
+
excludeChats: { value: "" },
|
|
15
|
+
includeSenders: { value: "" },
|
|
16
|
+
excludeSenders: { value: "" }
|
|
13
17
|
},
|
|
14
18
|
inputs: 1,
|
|
15
19
|
outputs: 2,
|
|
@@ -84,6 +88,50 @@
|
|
|
84
88
|
style="width: 60%"
|
|
85
89
|
/>
|
|
86
90
|
</div>
|
|
91
|
+
<div class="form-row">
|
|
92
|
+
<label for="node-input-includeChats">
|
|
93
|
+
<i class="fa fa-plus-circle"></i> Include chats
|
|
94
|
+
</label>
|
|
95
|
+
<textarea
|
|
96
|
+
id="node-input-includeChats"
|
|
97
|
+
placeholder="Enter chat IDs, one per line"
|
|
98
|
+
style="width: 60%"
|
|
99
|
+
></textarea>
|
|
100
|
+
<p class="form-tips">Only listen to messages from these chats. Leave blank to include all.</p>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="form-row">
|
|
103
|
+
<label for="node-input-excludeChats">
|
|
104
|
+
<i class="fa fa-minus-circle"></i> Exclude chats
|
|
105
|
+
</label>
|
|
106
|
+
<textarea
|
|
107
|
+
id="node-input-excludeChats"
|
|
108
|
+
placeholder="Enter chat IDs, one per line"
|
|
109
|
+
style="width: 60%"
|
|
110
|
+
></textarea>
|
|
111
|
+
<p class="form-tips">Ignore messages from these chats. Leave blank to exclude none.</p>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="form-row">
|
|
114
|
+
<label for="node-input-includeSenders">
|
|
115
|
+
<i class="fa fa-user-plus"></i> Include senders
|
|
116
|
+
</label>
|
|
117
|
+
<textarea
|
|
118
|
+
id="node-input-includeSenders"
|
|
119
|
+
placeholder="Enter sender IDs, one per line"
|
|
120
|
+
style="width: 60%"
|
|
121
|
+
></textarea>
|
|
122
|
+
<p class="form-tips">Only listen to messages from these senders. Leave blank to include all.</p>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="form-row">
|
|
125
|
+
<label for="node-input-excludeSenders">
|
|
126
|
+
<i class="fa fa-user-times"></i> Exclude senders
|
|
127
|
+
</label>
|
|
128
|
+
<textarea
|
|
129
|
+
id="node-input-excludeSenders"
|
|
130
|
+
placeholder="Enter sender IDs, one per line"
|
|
131
|
+
style="width: 60%"
|
|
132
|
+
></textarea>
|
|
133
|
+
<p class="form-tips">Ignore messages from these senders. Leave blank to exclude none.</p>
|
|
134
|
+
</div>
|
|
87
135
|
</script>
|
|
88
136
|
|
|
89
137
|
<script type="text/html" data-help-name="receiver">
|
|
@@ -134,6 +182,26 @@
|
|
|
134
182
|
<span class="property-type">number</span>
|
|
135
183
|
</dt>
|
|
136
184
|
<dd>Skip updates that include media exceeding this size. Leave blank to process all media.</dd>
|
|
185
|
+
|
|
186
|
+
<dt>Include chats
|
|
187
|
+
<span class="property-type">string</span>
|
|
188
|
+
</dt>
|
|
189
|
+
<dd>Newline-separated list of chat IDs to listen to. Leave blank to listen to all chats.</dd>
|
|
190
|
+
|
|
191
|
+
<dt>Exclude chats
|
|
192
|
+
<span class="property-type">string</span>
|
|
193
|
+
</dt>
|
|
194
|
+
<dd>Newline-separated list of chat IDs to ignore. Leave blank to exclude none.</dd>
|
|
195
|
+
|
|
196
|
+
<dt>Include senders
|
|
197
|
+
<span class="property-type">string</span>
|
|
198
|
+
</dt>
|
|
199
|
+
<dd>Newline-separated list of sender IDs to listen to. Leave blank to listen to all senders.</dd>
|
|
200
|
+
|
|
201
|
+
<dt>Exclude senders
|
|
202
|
+
<span class="property-type">string</span>
|
|
203
|
+
</dt>
|
|
204
|
+
<dd>Newline-separated list of sender IDs to ignore. Leave blank to exclude none.</dd>
|
|
137
205
|
</dl>
|
|
138
206
|
|
|
139
207
|
<h3>Details</h3>
|
package/nodes/receiver.js
CHANGED
|
@@ -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 {
|
|
@@ -358,6 +371,11 @@ module.exports = function (RED) {
|
|
|
358
371
|
? maxFileSizeMb * 1024 * 1024
|
|
359
372
|
: null;
|
|
360
373
|
|
|
374
|
+
const includeChats = splitList(config.includeChats || "");
|
|
375
|
+
const excludeChats = splitList(config.excludeChats || "");
|
|
376
|
+
const includeSenders = splitList(config.includeSenders || "");
|
|
377
|
+
const excludeSenders = splitList(config.excludeSenders || "");
|
|
378
|
+
|
|
361
379
|
const extractPhotoSize = (photo) => {
|
|
362
380
|
if (!photo || !Array.isArray(photo.sizes)) {
|
|
363
381
|
return null;
|
|
@@ -438,7 +456,13 @@ module.exports = function (RED) {
|
|
|
438
456
|
node.send([null, { payload }]);
|
|
439
457
|
};
|
|
440
458
|
|
|
441
|
-
|
|
459
|
+
let rawOptions = {};
|
|
460
|
+
if (includeChats.length > 0) rawOptions.chats = includeChats;
|
|
461
|
+
if (excludeChats.length > 0) rawOptions.blacklistChats = excludeChats;
|
|
462
|
+
if (includeSenders.length > 0) rawOptions.senders = includeSenders;
|
|
463
|
+
if (excludeSenders.length > 0) rawOptions.blacklistSenders = excludeSenders;
|
|
464
|
+
|
|
465
|
+
const event = new Raw(rawOptions);
|
|
442
466
|
const handler = (rawUpdate) => {
|
|
443
467
|
const debug = node.debugEnabled;
|
|
444
468
|
if (debug) {
|
package/package.json
CHANGED
package/test/receiver.test.js
CHANGED
|
@@ -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
|
});
|