Browse Source

Fx chat name resolve

painor 3 years ago
parent
commit
20441153be
4 changed files with 14 additions and 12 deletions
  1. 1 1
      gramjs/Version.ts
  2. 10 8
      gramjs/sessions/Memory.ts
  3. 2 2
      package-lock.json
  4. 1 1
      package.json

+ 1 - 1
gramjs/Version.ts

@@ -1 +1 @@
-export const version = "2.0.1";
+export const version = "2.0.2";

+ 10 - 8
gramjs/sessions/Memory.ts

@@ -279,28 +279,30 @@ export class MemorySession extends Session {
         }
         }
 
 
         let result = undefined;
         let result = undefined;
-        if (typeof key == "number") {
-            key = key.toString();
-        }
         if (typeof key === "string") {
         if (typeof key === "string") {
-            const id = utils.parseID(key);
-            if (id) {
-                result = this.getEntityRowsById(id, exact);
+            const phone = utils.parsePhone(key);
+            if (phone) {
+                result = this.getEntityRowsByPhone(phone);
             } else {
             } else {
                 const { username, isInvite } = utils.parseUsername(key);
                 const { username, isInvite } = utils.parseUsername(key);
                 if (username && !isInvite) {
                 if (username && !isInvite) {
                     result = this.getEntityRowsByUsername(username);
                     result = this.getEntityRowsByUsername(username);
                 }
                 }
             }
             }
+            if (!result) {
+                const id = utils.parseID(key);
+                if (id) {
+                    result = this.getEntityRowsById(id, exact);
+                }
+            }
             if (!result) {
             if (!result) {
                 result = this.getEntityRowsByName(key);
                 result = this.getEntityRowsByName(key);
             }
             }
         }
         }
-
         if (result) {
         if (result) {
             let entityId = result[0]; // unpack resulting tuple
             let entityId = result[0]; // unpack resulting tuple
             const entityHash = bigInt(result[1]);
             const entityHash = bigInt(result[1]);
-            const resolved = utils.resolveId(entityId);
+            const resolved = utils.resolveId(returnBigInt(entityId));
             entityId = resolved[0];
             entityId = resolved[0];
             const kind = resolved[1];
             const kind = resolved[1];
             // removes the mark and returns type of entity
             // removes the mark and returns type of entity

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
 {
   "name": "telegram",
   "name": "telegram",
-  "version": "2.0.1",
+  "version": "2.0.2",
   "lockfileVersion": 2,
   "lockfileVersion": 2,
   "requires": true,
   "requires": true,
   "packages": {
   "packages": {
     "": {
     "": {
       "name": "telegram",
       "name": "telegram",
-      "version": "2.0.1",
+      "version": "2.0.2",
       "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": "2.0.1",
+  "version": "2.0.2",
   "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",