teleproto 1.221.4 → 1.222.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/Version.d.ts +1 -1
- package/Version.js +1 -1
- package/client/TelegramClient.js +6 -0
- package/client/telegramBaseClient.d.ts +1 -1
- package/client/telegramBaseClient.js +1 -0
- package/client/updates.js +31 -22
- package/package.json +1 -1
- package/tl/AllTLObjects.d.ts +1 -1
- package/tl/AllTLObjects.js +1 -1
- package/tl/api.d.ts +33951 -33736
- package/tl/apiTl.js +42 -30
package/Version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.222.0";
|
package/Version.js
CHANGED
package/client/TelegramClient.js
CHANGED
|
@@ -1137,6 +1137,12 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
|
|
|
1137
1137
|
console.error(e);
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
|
+
// Restart update loop if it was stopped during reconnect
|
|
1141
|
+
if (!this._loopStarted && !this._destroyed) {
|
|
1142
|
+
this._log.info("Restarting update loop after reconnect");
|
|
1143
|
+
(0, updates_1._updateLoop)(this);
|
|
1144
|
+
this._loopStarted = true;
|
|
1145
|
+
}
|
|
1140
1146
|
}
|
|
1141
1147
|
//region base methods
|
|
1142
1148
|
async connect() {
|
|
@@ -179,7 +179,7 @@ export declare abstract class TelegramBaseClient {
|
|
|
179
179
|
/** @hidden */
|
|
180
180
|
private _exportedSenderReleaseTimeouts;
|
|
181
181
|
/** @hidden */
|
|
182
|
-
|
|
182
|
+
_loopStarted: boolean;
|
|
183
183
|
/** @hidden */
|
|
184
184
|
_updateState?: {
|
|
185
185
|
pts: number;
|
package/client/updates.js
CHANGED
|
@@ -292,31 +292,21 @@ async function _dispatchUpdate(client, args) {
|
|
|
292
292
|
}
|
|
293
293
|
/** @hidden */
|
|
294
294
|
async function _updateLoop(client) {
|
|
295
|
-
|
|
296
|
-
if (!client._updateState) {
|
|
297
|
-
try {
|
|
298
|
-
const state = await client.invoke(new tl_1.Api.updates.GetState());
|
|
299
|
-
client._updateState = {
|
|
300
|
-
pts: state.pts,
|
|
301
|
-
qts: state.qts,
|
|
302
|
-
date: state.date,
|
|
303
|
-
seq: state.seq,
|
|
304
|
-
};
|
|
305
|
-
client._log.debug("Initialized update state");
|
|
306
|
-
}
|
|
307
|
-
catch (e) {
|
|
308
|
-
client._log.error(`Failed to get initial update state: ${e}`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
295
|
+
var _a, _b;
|
|
311
296
|
let lastPongAt;
|
|
312
297
|
while (!client._destroyed) {
|
|
313
298
|
await (0, Helpers_1.sleep)(PING_INTERVAL, true);
|
|
314
|
-
if (client._destroyed
|
|
299
|
+
if (client._destroyed)
|
|
315
300
|
break;
|
|
316
|
-
if
|
|
301
|
+
// Check reconnecting state first - if reconnecting, skip this iteration
|
|
302
|
+
// but don't exit the loop
|
|
303
|
+
if (((_a = client._sender) === null || _a === void 0 ? void 0 : _a.isReconnecting) || client._isSwitchingDc) {
|
|
317
304
|
lastPongAt = undefined;
|
|
318
305
|
continue;
|
|
319
306
|
}
|
|
307
|
+
// Only exit if truly disconnected (not reconnecting)
|
|
308
|
+
if (client.disconnected)
|
|
309
|
+
break;
|
|
320
310
|
try {
|
|
321
311
|
const ping = () => {
|
|
322
312
|
return client._sender.send(new tl_1.Api.PingDelayDisconnect({
|
|
@@ -349,12 +339,17 @@ async function _updateLoop(client) {
|
|
|
349
339
|
}
|
|
350
340
|
client._log.error(`Ping failed: ${err}`);
|
|
351
341
|
lastPongAt = undefined;
|
|
352
|
-
if (client.
|
|
342
|
+
if (client._destroyed) {
|
|
353
343
|
break;
|
|
354
344
|
}
|
|
355
|
-
if
|
|
345
|
+
// Check reconnecting state first - if reconnecting, skip this iteration
|
|
346
|
+
if (((_b = client._sender) === null || _b === void 0 ? void 0 : _b.isReconnecting) || client._isSwitchingDc) {
|
|
356
347
|
continue;
|
|
357
348
|
}
|
|
349
|
+
// Only exit if truly disconnected (not reconnecting)
|
|
350
|
+
if (client.disconnected) {
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
358
353
|
client._sender.reconnect();
|
|
359
354
|
}
|
|
360
355
|
// We need to send some content-related request at least hourly
|
|
@@ -370,14 +365,28 @@ async function _updateLoop(client) {
|
|
|
370
365
|
client._updateState.date = state.date;
|
|
371
366
|
client._updateState.seq = state.seq;
|
|
372
367
|
}
|
|
368
|
+
else {
|
|
369
|
+
// Initialize update state if not yet set
|
|
370
|
+
client._updateState = {
|
|
371
|
+
pts: state.pts,
|
|
372
|
+
qts: state.qts,
|
|
373
|
+
date: state.date,
|
|
374
|
+
seq: state.seq,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
373
377
|
}
|
|
374
378
|
catch (e) {
|
|
375
|
-
//
|
|
379
|
+
// Ignore auth errors - user might not be logged in yet
|
|
376
380
|
}
|
|
377
381
|
lastPongAt = undefined;
|
|
378
382
|
}
|
|
379
383
|
}
|
|
380
|
-
|
|
384
|
+
// Mark loop as stopped so it can be restarted if needed
|
|
385
|
+
client._loopStarted = false;
|
|
386
|
+
// Only call disconnect if client was explicitly destroyed
|
|
387
|
+
if (client._destroyed) {
|
|
388
|
+
await client.disconnect();
|
|
389
|
+
}
|
|
381
390
|
}
|
|
382
391
|
/** @hidden */
|
|
383
392
|
async function attempts(cb, times, pause) {
|
package/package.json
CHANGED
package/tl/AllTLObjects.d.ts
CHANGED
package/tl/AllTLObjects.js
CHANGED