mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
improve
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@bot-whatsapp/cli": "*",
|
||||
"kleur": "^4.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -12,5 +12,8 @@
|
||||
},
|
||||
"files": [
|
||||
"./lib/cli/bundle.cli.cjs"
|
||||
]
|
||||
],
|
||||
"bin": {
|
||||
"bot": "./bin/cli.js"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
const inout = require('./io')
|
||||
const botcore = require('./core')
|
||||
|
||||
module.exports = { inout, botcore }
|
||||
@@ -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 `,
|
||||
],
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user