Added Option to skip QR Logging in Terminal (#552)

QR logging can now be disabled using connect option.
This commit is contained in:
bhavya32
2021-06-27 19:02:47 +05:30
committed by GitHub
parent 3607357152
commit 0dea009f9c
4 changed files with 11 additions and 2 deletions

View File

@@ -110,6 +110,8 @@ conn.connectOptions = {
fetchAgent?: Agent = undefined, fetchAgent?: Agent = undefined,
/** always uses takeover for connecting */ /** always uses takeover for connecting */
alwaysUseTakeover: true alwaysUseTakeover: true
/** log QR to terminal */
logQR: true
} as WAConnectOptions } as WAConnectOptions
``` ```

View File

@@ -48,7 +48,8 @@ export class WAConnection extends EventEmitter {
phoneResponseTime: 15_000, phoneResponseTime: 15_000,
maxQueryResponseTime: 10_000, maxQueryResponseTime: 10_000,
alwaysUseTakeover: true, alwaysUseTakeover: true,
queryChatsTillReceived: true queryChatsTillReceived: true,
logQR: true
} }
/** When to auto-reconnect */ /** When to auto-reconnect */
autoReconnect = ReconnectMode.onConnectionLost autoReconnect = ReconnectMode.onConnectionLost

View File

@@ -387,7 +387,11 @@ export class WAConnection extends Base {
this.logger.warn('recieved read update for unknown chat ' + jid) this.logger.warn('recieved read update for unknown chat ' + jid)
} }
}) })
this.on ('qr', qr => QR.generate(qr, { small: true })) this.on('qr', qr => {
if (this.connectOptions.logQR) {
QR.generate(qr, { small: true })
}
});
// blocklist updates // blocklist updates
this.on('CB:Blocklist', json => { this.on('CB:Blocklist', json => {

View File

@@ -136,6 +136,8 @@ export type WAConnectOptions = {
queryChatsTillReceived?: boolean queryChatsTillReceived?: boolean
/** max time for the phone to respond to a query */ /** max time for the phone to respond to a query */
maxQueryResponseTime?: number maxQueryResponseTime?: number
/** Log QR to terminal or not */
logQR?: boolean
} }
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi