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