Ver código fonte

Add divider as an option for storeSession

painor 3 anos atrás
pai
commit
8548c11633

+ 1 - 1
gramjs/Version.ts

@@ -1 +1 @@
-export const version = "2.0.14";
+export const version = "2.0.15";

+ 1 - 1
gramjs/client/updates.ts

@@ -122,7 +122,7 @@ export async function _dispatchUpdate(
         let event = args.update;
         let event = args.update;
         if (event) {
         if (event) {
             if (!client._selfInputPeer) {
             if (!client._selfInputPeer) {
-                client.getMe(true).catch(()=>{
+                client.getMe(true).catch(() => {
                     // do nothing
                     // do nothing
                 });
                 });
             }
             }

+ 7 - 1
gramjs/sessions/Memory.ts

@@ -254,7 +254,13 @@ export class MemorySession extends Session {
                 exact = false;
                 exact = false;
             }
             }
         }
         }
-
+        if (
+            bigInt.isInstance(key) ||
+            typeof key == "bigint" ||
+            typeof key == "number"
+        ) {
+            key = key.toString();
+        }
         let result = undefined;
         let result = undefined;
         if (typeof key === "string") {
         if (typeof key === "string") {
             const phone = utils.parsePhone(key);
             const phone = utils.parsePhone(key);

+ 5 - 2
gramjs/sessions/StoreSession.ts

@@ -7,7 +7,7 @@ export class StoreSession extends MemorySession {
     private readonly sessionName: string;
     private readonly sessionName: string;
     private store: store.StoreAPI;
     private store: store.StoreAPI;
 
 
-    constructor(sessionName: string) {
+    constructor(sessionName: string, divider = ":") {
         super();
         super();
         if (typeof localStorage === "undefined" || localStorage === null) {
         if (typeof localStorage === "undefined" || localStorage === null) {
             const LocalStorage = require("node-localstorage").LocalStorage;
             const LocalStorage = require("node-localstorage").LocalStorage;
@@ -15,7 +15,10 @@ export class StoreSession extends MemorySession {
         } else {
         } else {
             this.store = store.area("fs", localStorage);
             this.store = store.area("fs", localStorage);
         }
         }
-        this.sessionName = sessionName + ":";
+        if (divider == undefined) {
+            divider = ":";
+        }
+        this.sessionName = sessionName + divider;
     }
     }
 
 
     async load() {
     async load() {

+ 2 - 2
package-lock.json

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