Przeglądaj źródła

limit lastAcks array to 10 elements.

painor 3 lat temu
rodzic
commit
d7be6bf372

+ 1 - 1
gramjs/Helpers.ts

@@ -61,7 +61,7 @@ export function betterConsoleLog(object: { [key: string]: any }) {
     const toPrint: { [key: string]: any } = {};
     const toPrint: { [key: string]: any } = {};
     for (const key in object) {
     for (const key in object) {
         if (object.hasOwnProperty(key)) {
         if (object.hasOwnProperty(key)) {
-            if (!key.startsWith("_")) {
+            if (!key.startsWith("_") && key!="originalArgs") {
                 toPrint[key] = object[key];
                 toPrint[key] = object[key];
             }
             }
         }
         }

+ 1 - 1
gramjs/Version.ts

@@ -1 +1 @@
-export const version = "1.10.4";
+export const version = "1.10.7";

+ 2 - 2
gramjs/client/updates.ts

@@ -7,8 +7,8 @@ import type { Raw } from "../events";
 import { utils } from "../index";
 import { utils } from "../index";
 import { getRandomInt, sleep } from "../Helpers";
 import { getRandomInt, sleep } from "../Helpers";
 
 
-const PING_INTERVAL = 3000; // 3 sec
-const PING_TIMEOUT = 5000; // 5 sec
+const PING_INTERVAL = 9000; // 9 sec
+const PING_TIMEOUT = 10000; // 10 sec
 const PING_FAIL_ATTEMPTS = 3;
 const PING_FAIL_ATTEMPTS = 3;
 const PING_FAIL_INTERVAL = 100; // ms
 const PING_FAIL_INTERVAL = 100; // ms
 const PING_DISCONNECT_DELAY = 60000; // 1 min
 const PING_DISCONNECT_DELAY = 60000; // 1 min

+ 3 - 0
gramjs/network/MTProtoSender.ts

@@ -403,6 +403,9 @@ export class MTProtoSender {
                 );
                 );
                 this._sendQueue.append(ack);
                 this._sendQueue.append(ack);
                 this._lastAcks.push(ack);
                 this._lastAcks.push(ack);
+                if (this._lastAcks.length >= 10){
+                    this._lastAcks.shift();
+                }
                 this._pendingAck.clear();
                 this._pendingAck.clear();
             }
             }
             this._log.debug(
             this._log.debug(

+ 5 - 0
gramjs/tl/api.js

@@ -1,9 +1,11 @@
+const { inspect } = require("util");
 const bigInt = require("big-integer");
 const bigInt = require("big-integer");
 
 
 const {
 const {
     generateRandomBytes,
     generateRandomBytes,
     readBigIntFromBuffer,
     readBigIntFromBuffer,
     isArrayLike,
     isArrayLike,
+    betterConsoleLog,
 } = require("../Helpers");
 } = require("../Helpers");
 
 
 function generateRandomBigInt() {
 function generateRandomBigInt() {
@@ -579,6 +581,9 @@ function createClasses(classesType, params) {
                     }
                     }
                 }
                 }
             }
             }
+            [inspect.custom]() {
+                return betterConsoleLog(this);
+            }
 
 
             toJSON() {
             toJSON() {
                 return this.originalArgs;
                 return this.originalArgs;

+ 1 - 1
gramjs/tl/custom/message.ts

@@ -794,7 +794,7 @@ export class CustomMessage extends SenderGetter {
         return this._client.editMessage((await this.getInputChat())!, param);
         return this._client.editMessage((await this.getInputChat())!, param);
     }
     }
 
 
-    async delete({ revoke = false }) {
+    async delete({ revoke } = { revoke: false }) {
         if (this._client) {
         if (this._client) {
             return this._client.deleteMessages(
             return this._client.deleteMessages(
                 await this.getInputChat(),
                 await this.getInputChat(),

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
 {
   "name": "telegram",
   "name": "telegram",
-  "version": "1.10.4",
+  "version": "1.10.7",
   "lockfileVersion": 2,
   "lockfileVersion": 2,
   "requires": true,
   "requires": true,
   "packages": {
   "packages": {
     "": {
     "": {
       "name": "telegram",
       "name": "telegram",
-      "version": "1.10.4",
+      "version": "1.10.7",
       "license": "MIT",
       "license": "MIT",
       "dependencies": {
       "dependencies": {
         "@cryptography/aes": "^0.1.1",
         "@cryptography/aes": "^0.1.1",

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "telegram",
   "name": "telegram",
-  "version": "1.10.4",
+  "version": "1.10.7",
   "description": "NodeJS/Browser MTProto API Telegram client library,",
   "description": "NodeJS/Browser MTProto API Telegram client library,",
   "main": "index.js",
   "main": "index.js",
   "types": "index.d.ts",
   "types": "index.d.ts",