painor 5 anni fa
parent
commit
3d5d64bfaf

+ 1 - 3
gramjs/client/TelegramClient.js

@@ -60,7 +60,6 @@ class TelegramClient {
             try {
             try {
                 session = new SQLiteSession(session)
                 session = new SQLiteSession(session)
             } catch (e) {
             } catch (e) {
-                console.log(e)
                 session = new MemorySession()
                 session = new MemorySession()
             }
             }
         } else if (!(session instanceof Session)) {
         } else if (!(session instanceof Session)) {
@@ -253,7 +252,6 @@ class TelegramClient {
                     e instanceof errors.UserMigrateError) {
                     e instanceof errors.UserMigrateError) {
                     this._log.info(`Phone migrated to ${e.newDc}`)
                     this._log.info(`Phone migrated to ${e.newDc}`)
                     const shouldRaise = e instanceof errors.PhoneMigrateError || e instanceof errors.NetworkMigrateError
                     const shouldRaise = e instanceof errors.PhoneMigrateError || e instanceof errors.NetworkMigrateError
-                    console.log('should I raise ? ', shouldRaise)
                     if (shouldRaise && await this.isUserAuthorized()) {
                     if (shouldRaise && await this.isUserAuthorized()) {
                         throw e
                         throw e
                     }
                     }
@@ -454,7 +452,7 @@ class TelegramClient {
 
 
     // endregion
     // endregion
     async isUserAuthorized() {
     async isUserAuthorized() {
-        if (!this._authorized) {
+        if (this._authorized === undefined || this._authorized === null) {
             try {
             try {
                 await this.invoke(new functions.updates.GetStateRequest())
                 await this.invoke(new functions.updates.GetStateRequest())
                 this._authorized = true
                 this._authorized = true

+ 0 - 1
gramjs/errors/Common.js

@@ -45,7 +45,6 @@ class InvalidChecksumError extends Error {
  */
  */
 class InvalidBufferError extends Error {
 class InvalidBufferError extends Error {
     constructor(payload) {
     constructor(payload) {
-        console.log('payload is ', payload)
         if (payload.length === 4) {
         if (payload.length === 4) {
             const code = -(struct.unpack('<i', payload)[0])
             const code = -(struct.unpack('<i', payload)[0])
             super(`Invalid response buffer (HTTP code ${code})`)
             super(`Invalid response buffer (HTTP code ${code})`)

+ 0 - 2
gramjs/network/Authenticator.js

@@ -29,10 +29,8 @@ async function doAuthentication(sender, log) {
     let bytes = Helpers.generateRandomBytes(16)
     let bytes = Helpers.generateRandomBytes(16)
 
 
     const nonce = Helpers.readBigIntFromBuffer(bytes, false, true)
     const nonce = Helpers.readBigIntFromBuffer(bytes, false, true)
-    console.log('our nonce is ', nonce)
     const resPQ = await sender.send(new ReqPqMultiRequest({ nonce: nonce }))
     const resPQ = await sender.send(new ReqPqMultiRequest({ nonce: nonce }))
     log.debug('Starting authKey generation step 1')
     log.debug('Starting authKey generation step 1')
-    console.log('got result is ', resPQ)
     if (!(resPQ instanceof ResPQ)) {
     if (!(resPQ instanceof ResPQ)) {
         throw new Error(`Step 1 answer was ${resPQ}`)
         throw new Error(`Step 1 answer was ${resPQ}`)
     }
     }

+ 1 - 7
gramjs/network/MTProtoSender.js

@@ -343,7 +343,6 @@ class MTProtoSender {
                     this._log.info('Broken authorization key; resetting')
                     this._log.info('Broken authorization key; resetting')
                     this.authKey.key = null
                     this.authKey.key = null
                     if (this._authKeyCallback) {
                     if (this._authKeyCallback) {
-                        console.log('called auth callback')
                         await this._authKeyCallback(null)
                         await this._authKeyCallback(null)
                     }
                     }
                     this._startReconnect(e)
                     this._startReconnect(e)
@@ -452,7 +451,6 @@ class MTProtoSender {
                     throw new TypeNotFoundError('Not an upload.File')
                     throw new TypeNotFoundError('Not an upload.File')
                 }
                 }
             } catch (e) {
             } catch (e) {
-                console.log(e)
                 if (e instanceof TypeNotFoundError) {
                 if (e instanceof TypeNotFoundError) {
                     this._log.info(`Received response without parent request: ${RPCResult.body}`)
                     this._log.info(`Received response without parent request: ${RPCResult.body}`)
                     return
                     return
@@ -719,11 +717,10 @@ class MTProtoSender {
         await this._connection.disconnect()
         await this._connection.disconnect()
         this._reconnecting = false
         this._reconnecting = false
         this._state.reset()
         this._state.reset()
-        const retries = 1 //this._retries
+        const retries = this._retries
         for (let attempt = 0; attempt < retries; attempt++) {
         for (let attempt = 0; attempt < retries; attempt++) {
             try {
             try {
                 await this._connect()
                 await this._connect()
-                console.log('fiinsihed connecting')
                 this._send_queue.extend(Object.values(this._pending_state))
                 this._send_queue.extend(Object.values(this._pending_state))
                 this._pending_state = {}
                 this._pending_state = {}
                 if (this._autoReconnectCallback) {
                 if (this._autoReconnectCallback) {
@@ -731,9 +728,6 @@ class MTProtoSender {
                 }
                 }
                 break
                 break
             } catch (e) {
             } catch (e) {
-                console.log(e.stack)
-
-                console.log('ok why did i get this error ?')
                 this._log.error(e)
                 this._log.error(e)
                 await Helpers.sleep(this._delay)
                 await Helpers.sleep(this._delay)
             }
             }

+ 0 - 1
gramjs/sessions/Memory.js

@@ -131,7 +131,6 @@ class MemorySession extends Session {
         }
         }
         const rows = [] // Rows to add (id, hash, username, phone, name)
         const rows = [] // Rows to add (id, hash, username, phone, name)
         for (const e of entities) {
         for (const e of entities) {
-            console.log('enttiy is ', e)
             const row = this._entityToRow(e)
             const row = this._entityToRow(e)
             if (row) {
             if (row) {
                 rows.push(row)
                 rows.push(row)

+ 0 - 4
gramjs/sessions/SQLiteSession.js

@@ -209,18 +209,14 @@ class SQLiteSession extends MemorySession {
         if (!this.saveEntities) {
         if (!this.saveEntities) {
             return
             return
         }
         }
-        console.log(tlo)
         const rows = this._entitiesToRows(tlo)
         const rows = this._entitiesToRows(tlo)
-        console.log(rows)
         if (!rows) {
         if (!rows) {
             return
             return
         }
         }
         for (const row of rows) {
         for (const row of rows) {
             row[1] = Database.Integer(row[1].toString())
             row[1] = Database.Integer(row[1].toString())
-            console.log('row to be added', row)
             const stmt = this.db.prepare('insert or replace into entities values (?,?,?,?,?)')
             const stmt = this.db.prepare('insert or replace into entities values (?,?,?,?,?)')
             stmt.run(...row)
             stmt.run(...row)
-            console.log('row added :D', ...row)
         }
         }
     }
     }