mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-18 03:29:15 +00:00
feat: ⚡ qr code filename
This commit is contained in:
@@ -19,13 +19,15 @@ const serve = require('serve-static')(dir)
|
||||
* Iniciamos Portal WEB para escanear QR
|
||||
* @param {port:3000, publicSite:'http://mistio.com', qrFile:'qr.png', dir:__dirname}
|
||||
*/
|
||||
const start = (
|
||||
{ port, publicSite, qrFile } = {
|
||||
const start = (args) => {
|
||||
const injectArgs = {
|
||||
port: HTTP_PORT,
|
||||
publicSite: PUBLIC_URL,
|
||||
qrFile: QR_FILE,
|
||||
...args,
|
||||
}
|
||||
) => {
|
||||
const { port, publicSite, qrFile } = injectArgs
|
||||
|
||||
polka()
|
||||
.use(serve)
|
||||
.get(qrFile, (_, res) => {
|
||||
|
||||
@@ -33,10 +33,12 @@ const PATH_BASE = join(process.cwd(), NAME_DIR_SESSION)
|
||||
* https://github.com/adiwajshing/Baileys
|
||||
*/
|
||||
class BaileysProvider extends ProviderClass {
|
||||
globalVendorArgs = { qrFile: 'qr.png' }
|
||||
vendor
|
||||
saveCredsGlobal = null
|
||||
constructor() {
|
||||
constructor(args) {
|
||||
super()
|
||||
this.globalVendorArgs = { ...this.globalVendorArgs, ...args }
|
||||
this.initBailey().then()
|
||||
}
|
||||
|
||||
@@ -93,7 +95,7 @@ class BaileysProvider extends ProviderClass {
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
})
|
||||
await baileyGenerateImage(qr)
|
||||
await baileyGenerateImage(qr, this.globalVendorArgs.qrFile)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ const baileyCleanNumber = (number, full = false) => {
|
||||
* Hace promesa el write
|
||||
* @param {*} base64
|
||||
*/
|
||||
const baileyGenerateImage = async (base64) => {
|
||||
const PATH_QR = `${process.cwd()}/qr.png`
|
||||
const baileyGenerateImage = async (base64, name = 'qr.png') => {
|
||||
const PATH_QR = `${process.cwd()}/${name}`
|
||||
let qr_svg = qr.image(base64, { type: 'png', margin: 4 })
|
||||
|
||||
const writeFilePromise = () =>
|
||||
|
||||
@@ -20,9 +20,11 @@ const logger = new Console({
|
||||
* https://github.com/orkestral/venom
|
||||
*/
|
||||
class VenomProvider extends ProviderClass {
|
||||
globalVendorArgs = { qrFile: 'qr.png' }
|
||||
vendor
|
||||
constructor() {
|
||||
constructor(args) {
|
||||
super()
|
||||
this.globalVendorArgs = { ...this.globalVendorArgs, ...args }
|
||||
this.init().then(() => this.initBusEvents())
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ const venomCleanNumber = (number, full = false) => {
|
||||
return number
|
||||
}
|
||||
|
||||
const venomGenerateImage = async (base) => {
|
||||
const PATH_QR = `${process.cwd()}/qr.png`
|
||||
const venomGenerateImage = async (base, name = 'qr.png') => {
|
||||
const PATH_QR = `${process.cwd()}/${name}`
|
||||
const matches = base.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/)
|
||||
if (matches.length !== 3) {
|
||||
return new Error('Invalid input string')
|
||||
|
||||
@@ -19,9 +19,11 @@ const logger = new Console({
|
||||
* https://github.com/pedroslopez/whatsapp-web.js
|
||||
*/
|
||||
class WebWhatsappProvider extends ProviderClass {
|
||||
globalVendorArgs = { qrFile: 'qr.png' }
|
||||
vendor
|
||||
constructor() {
|
||||
constructor(args) {
|
||||
super()
|
||||
this.globalVendorArgs = { ...this.globalVendorArgs, ...args }
|
||||
this.vendor = new Client({
|
||||
authStrategy: new LocalAuth(),
|
||||
puppeteer: {
|
||||
|
||||
@@ -11,8 +11,8 @@ const wwebCleanNumber = (number, full = false) => {
|
||||
return number
|
||||
}
|
||||
|
||||
const wwebGenerateImage = async (base64) => {
|
||||
const PATH_QR = `${process.cwd()}/qr.png`
|
||||
const wwebGenerateImage = async (base64, name = 'qr.png') => {
|
||||
const PATH_QR = `${process.cwd()}/${name}`
|
||||
let qr_svg = qr.image(base64, { type: 'png', margin: 4 })
|
||||
|
||||
const writeFilePromise = () =>
|
||||
|
||||
Reference in New Issue
Block a user