respect printQRInTerminal

This commit is contained in:
Adhiraj Singh
2021-09-25 23:30:59 +05:30
parent 1f6ef554c2
commit 070d4eebcc

View File

@@ -25,7 +25,8 @@ export const makeSocket = ({
keepAliveIntervalMs, keepAliveIntervalMs,
version, version,
browser, browser,
auth: initialAuthState auth: initialAuthState,
printQRInTerminal,
}: SocketConfig) => { }: SocketConfig) => {
const ws = new WebSocket(waWebSocketUrl, undefined, { const ws = new WebSocket(waWebSocketUrl, undefined, {
origin: DEFAULT_ORIGIN, origin: DEFAULT_ORIGIN,
@@ -400,10 +401,12 @@ export const makeSocket = ({
// QR gen // QR gen
ws.on('CB:iq,type:set,pair-device', async (stanza: BinaryNode) => { ws.on('CB:iq,type:set,pair-device', async (stanza: BinaryNode) => {
const postQR = async() => { const postQR = async() => {
const QR = await import('qrcode-terminal').catch(err => { if(printQRInTerminal) {
logger.error('add `qrcode-terminal` as a dependency to auto-print QR') const QR = await import('qrcode-terminal').catch(err => {
}) logger.error('add `qrcode-terminal` as a dependency to auto-print QR')
QR?.generate(qr, { small: true }) })
QR?.generate(qr, { small: true })
}
} }
const refs = ((stanza.content[0] as BinaryNode).content as BinaryNode[]).map(n => n.content as string) const refs = ((stanza.content[0] as BinaryNode).content as BinaryNode[]).map(n => n.content as string)