Przeglądaj źródła

Fix some typing issues.

painor 4 lat temu
rodzic
commit
28d2f84ffc

+ 2 - 2
gramjs/client/TelegramClient.ts

@@ -1084,7 +1084,7 @@ export class TelegramClient extends TelegramBaseClient {
         this.session.setDC(newDc, DC.ipAddress, DC.port);
         // authKey's are associated with a server, which has now changed
         // so it's not valid anymore. Set to undefined to force recreating it.
-        await this._sender.authKey.setKey();
+        await this._sender!.authKey.setKey();
         this.session.setAuthKey();
         await this.disconnect();
         return this.connect();
@@ -1134,7 +1134,7 @@ export class TelegramClient extends TelegramBaseClient {
             } catch (e) {
                 // we can't create sender for our own main DC
                 if (e.message == "DC_ID_INVALID") {
-                    return this._sender;
+                    return this._sender!;
                 }
                 await sender.disconnect();
             }

+ 2 - 2
gramjs/client/chats.ts

@@ -155,10 +155,10 @@ export class _ParticipantsIter extends RequestIter {
                     utils
                         .getDisplayName(entity)
                         .toLowerCase()
-                        .includes(<string>search) ||
+                        .includes(search!) ||
                     ("username" in entity ? entity.username || "" : "")
                         .toLowerCase()
-                        .includes(<string>search)
+                        .includes(search!)
                 );
             };
         } else {

+ 2 - 2
gramjs/client/downloads.ts

@@ -101,14 +101,14 @@ export async function downloadFile(
             // This should never raise
             if (e.message === "DC_ID_INVALID") {
                 // Can't export a sender for the ID we are currently in
-                sender = client._sender;
+                sender = client._sender!;
             } else {
                 client._log.error(e);
                 throw e;
             }
         }
     } else {
-        sender = client._sender;
+        sender = client._sender!;
     }
 
     client._log.info(`Downloading file in chunks of ${partSize} bytes`);

+ 3 - 2
gramjs/client/telegramBaseClient.ts

@@ -14,6 +14,7 @@ import { EntityCache } from "../entityCache";
 import type { ParseInterface } from "./messageParse";
 import type { EventBuilder } from "../events/common";
 import { MarkdownParser } from "../extensions/markdown";
+import { MTProtoSender } from "../network";
 
 const DEFAULT_DC_ID = 1;
 const DEFAULT_IPV4_IP = IS_NODE ? "149.154.167.51" : "pluto.web.telegram.org";
@@ -146,7 +147,7 @@ export class TelegramBaseClient {
     /** @hidden */
     public _initRequest: Api.InitConnection;
     /** @hidden */
-    public _sender?: any;
+    public _sender?: MTProtoSender;
     /** @hidden */
     public _floodWaitedRequests: any;
     /** @hidden */
@@ -263,7 +264,7 @@ export class TelegramBaseClient {
     }
 
     get disconnected() {
-        return !this._sender || this._sender.disconnected;
+        return !this._sender || this._sender._disconnected;
     }
 
     async destroy() {

+ 2 - 1
gramjs/client/updates.ts

@@ -144,12 +144,13 @@ export async function _updateLoop(client: TelegramClient): Promise<void> {
         // We don't care about the result we just want to send it every
         // 60 seconds so telegram doesn't stop the connection
         try {
-            client._sender.send(
+            client._sender!.send(
                 new Api.Ping({
                     pingId: bigInt(rnd)
                 })
             );
         } catch (e) {
+            //await client.disconnect()
         }
 
         // We need to send some content-related request at least hourly

+ 2 - 2
gramjs/network/MTProtoSender.ts

@@ -75,10 +75,10 @@ export class MTProtoSender {
     private readonly _isMainSender: boolean;
     private _userConnected: boolean;
     private _reconnecting: boolean;
-    private _disconnected: boolean;
+    _disconnected: boolean;
     private _sendLoopHandle: any;
     private _recvLoopHandle: any;
-    private readonly authKey: AuthKey;
+    readonly authKey: AuthKey;
     private readonly _state: MTProtoState;
     private _sendQueue: MessagePacker;
     private _pendingState: Map<string, RequestState>;

+ 1 - 1
gramjs/sessions/StringSession.ts

@@ -102,7 +102,7 @@ export class StringSession extends MemorySession {
                     addressLengthBuffer,
                     addressBuffer,
                     portBuffer,
-                    key,
+                    key
                 ])
             )
         );

+ 2 - 2
package-lock.json

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

+ 1 - 1
package.json

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