Skip to content

Commit

Permalink
feat: ⚡ qr portal
Browse files Browse the repository at this point in the history
  • Loading branch information
leifermendez committed Jan 10, 2023
1 parent 6417f8e commit af8b401
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
33 changes: 21 additions & 12 deletions packages/portal/portal.http.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { join } = require('path')
const { createReadStream, existsSync } = require('fs')
const { bgYellow, cyan } = require('kleur')
const { bgYellow, cyan, yellow } = require('kleur')
const polka = require('polka')

const HTTP_PORT = process.env.PORT || 3000
Expand Down Expand Up @@ -28,31 +28,40 @@ const start = (args) => {
}
const { port, publicSite, name } = injectArgs

const banner = () => {
console.log(``)
console.log(bgYellow(`🚩 ESCANEAR QR 🚩`))
console.log(cyan(`Existen varias maneras de escanear el QR code`))
console.log(
cyan(`- Tambien puedes visitar `),
yellow(`${publicSite}:${port}`)
)
console.log(
cyan(`- Se ha creado un archivo que finaliza `),
yellow('qr.png')
)
console.log(``)
}

polka()
.use(serve)
.get('qr.png', (_, res) => {
const qrSource = [
join(process.cwd(), `${name}.png`),
join(__dirname, '..', `${name}.png`),
join(__dirname, `${name}.png`),
join(process.cwd(), `${name}.qr.png`),
join(__dirname, '..', `${name}.qr.png`),
join(__dirname, `${name}.qr.png`),
].find((i) => existsSync(i))

const qrMark = [
join(__dirname, 'dist', 'water-mark.png'),
join(__dirname, '..', 'dist', 'water-mark.png'),
].find((i) => existsSync(i))
const fileStream = createReadStream(qrSource ?? qrMark)

res.writeHead(200, { 'Content-Type': 'image/png' })
fileStream.pipe(res)
})
.listen(port, () => {
console.log(``)
console.log(bgYellow(`🚩 ESCANEAR QR 🚩`))
console.log(cyan(`Existen varias maneras de escanear el QR code`))
console.log(cyan(`- Se ha creado un archivo /qr.png`))
console.log(cyan(`- Tambien puedes visitar ${publicSite}:${port}`))
console.log(``)
})
.listen(port, () => banner())
}

module.exports = start
2 changes: 1 addition & 1 deletion packages/provider/src/baileys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class BaileysProvider extends ProviderClass {
})
await baileyGenerateImage(
qr,
`${this.globalVendorArgs.name}.png`
`${this.globalVendorArgs.name}.qr.png`
)
}
})
Expand Down
9 changes: 6 additions & 3 deletions packages/provider/src/venom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ class VenomProvider extends ProviderClass {
{
session: NAME_DIR_SESSION,
multidevice: true,
disableSpins: true,
disableWelcome: true,
logger,
logQR: false,
},
(base) => this.generateQr(base),
undefined,
{ logQR: false }
undefined
)
this.vendor = client
} catch (e) {
Expand Down Expand Up @@ -69,7 +72,7 @@ class VenomProvider extends ProviderClass {
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
],
})
await venomGenerateImage(qr, `${this.globalVendorArgs.name}.png`)
await venomGenerateImage(qr, `${this.globalVendorArgs.name}.qr.png`)
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/provider/src/web-whatsapp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class WebWhatsappProvider extends ProviderClass {
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
],
})
await wwebGenerateImage(qr, `${this.globalVendorArgs.name}.png`)
await wwebGenerateImage(
qr,
`${this.globalVendorArgs.name}.qr.png`
)
},
},
{
Expand Down

0 comments on commit af8b401

Please sign in to comment.