Merge pull request #409 from codigoencasa/dev

Dev
This commit is contained in:
Leifer Mendez
2023-01-09 19:46:21 +01:00
committed by GitHub
13 changed files with 27 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/bot",
"version": "0.0.46-alpha.0",
"version": "0.0.47-alpha.0",
"description": "",
"main": "./lib/bundle.bot.cjs",
"scripts": {

View File

@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/cli",
"version": "0.0.53-alpha.0",
"version": "0.0.54-alpha.0",
"description": "",
"main": "index.js",
"devDependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "create-bot-whatsapp",
"version": "0.0.64-alpha.0",
"version": "0.0.65-alpha.0",
"description": "",
"main": "./lib/bundle.create-bot-whatsapp.cjs",
"files": [

View File

@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/database",
"version": "0.0.45-alpha.0",
"version": "0.0.46-alpha.0",
"description": "Esto es el conector a mysql, pg, mongo",
"main": "./lib/mock/index.cjs",
"keywords": [],

View File

@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/portal",
"version": "0.0.3-alpha.0",
"version": "0.0.4-alpha.0",
"description": "Portal WEB para escanear QR",
"main": "./lib/portal.http.cjs",
"scripts": {

View File

@@ -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) => {

View File

@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/provider",
"version": "0.0.51-alpha.0",
"version": "0.0.52-alpha.0",
"description": "Esto es el conector a Twilio, Meta, etc...",
"main": "./lib/mock/index.cjs",
"keywords": [],

View File

@@ -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)
}
})

View File

@@ -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 = () =>

View File

@@ -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())
}

View File

@@ -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')

View File

@@ -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: {

View File

@@ -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 = () =>