This commit is contained in:
Leifer Mendez
2022-11-14 20:52:38 +01:00
parent 9178bc083e
commit 5797beb0ca
12 changed files with 33 additions and 688 deletions

View File

@@ -25,8 +25,11 @@ const createFlow = (args) => {
* @param {*} args
* @returns
*/
const createProvider = (args) => {
return new FlowClass(args)
const createProvider = (providerClass = class {}) => {
const providerInstance = new providerClass()
if (!providerClass.prototype instanceof ProviderClass)
throw new Error('El provider no implementa ProviderClass')
return providerInstance
}
module.exports = {

View File

@@ -22,6 +22,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@bot-whatsapp/cli": "*",
"kleur": "^4.1.5"
}
}

View File

@@ -2,7 +2,7 @@ const { yellow, bgRed } = require('kleur')
const NODE_ENV = process.env.NODE_ENV || 'dev'
const printer = (message, title) => {
if (NODE_ENV !== 'test') {
console.clear()
// console.clear()
if (title) console.log(bgRed(`${title}`))
console.log(
yellow(Array.isArray(message) ? message.join('\n') : message)

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env node
const index = require('../../../lib/cli/bundle.cli.cjs')
const index = require('../lib/cli/bundle.cli.cjs')
index.startInteractive()

View File

@@ -5,6 +5,7 @@ const { installDeps, getPkgManage } = require('./tool')
const PATHS_DIR = [
join(__dirname, 'pkg-to-update.json'),
join(__dirname, '..', 'pkg-to-update.json'),
join(__dirname, '..', '..', 'pkg-to-update.json'),
]
const PKG_TO_UPDATE = () => {

View File

@@ -12,5 +12,8 @@
},
"files": [
"./lib/cli/bundle.cli.cjs"
]
],
"bin": {
"bot": "./bin/cli.js"
}
}

View File

@@ -1,4 +0,0 @@
const inout = require('./io')
const botcore = require('./core')
module.exports = { inout, botcore }

View File

@@ -1,5 +1,11 @@
const { Client, LocalAuth } = require('whatsapp-web.js')
const { ProviderClass } = require('@bot-whatsapp/bot')
const { Console } = require('console')
const { createWriteStream } = require('fs')
const logger = new Console({
stdout: createWriteStream('./log'),
})
const { cleanNumber, generateImage, isValidNumber } = require('./utils')
@@ -17,14 +23,15 @@ class WebWhatsappProvider extends ProviderClass {
this.vendor.on(event, func)
}
this.vendor.initialize().catch((e) =>
this.vendor.initialize().catch((e) => {
logger.log(e)
this.emit('require_action', {
instructions: [
`Debes eliminar la carpeta .wwebjs_auth`,
`y reiniciar nuevamente el bot `,
],
})
)
})
}
/**