瀏覽代碼

Fix entity caching

painor 4 年之前
父節點
當前提交
3b17ff94f1
共有 3 個文件被更改,包括 15 次插入12 次删除
  1. 12 9
      gramjs/entityCache.ts
  2. 2 2
      package-lock.json
  3. 1 1
      package.json

+ 12 - 9
gramjs/entityCache.ts

@@ -15,15 +15,18 @@ export class EntityCache {
 
         const temp = [];
         if (!isArrayLike(entities)) {
-
-            if ('chats' in entities) {
-                temp.push(...entities.chats)
-            }
-            if ('users' in entities) {
-                temp.push(...entities.users)
-            }
-            if ('user' in entities) {
-                temp.push(entities.user)
+            if (entities != undefined){
+                if (typeof entities == 'object'){
+                    if ('chats' in entities) {
+                        temp.push(...entities.chats)
+                    }
+                    if ('users' in entities) {
+                        temp.push(...entities.users)
+                    }
+                    if ('user' in entities) {
+                        temp.push(entities.user)
+                    }
+                }
             }
             if (temp.length) {
                 entities = temp;

+ 2 - 2
package-lock.json

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

+ 1 - 1
package.json

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