mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-19 12:09:15 +00:00
Update Julio 2022
Se añade localAuth para mantener la session despues de escanear el codigo y se hace un code fix al api rest Co-Authored-By: Leifer Mendez <15802366+leifermendez@users.noreply.github.com>
This commit is contained in:
@@ -64,32 +64,14 @@ const checkEnvFile = () => {
|
||||
* @param {*} session
|
||||
* @param {*} cb
|
||||
*/
|
||||
const createClient = (session = {}, login = false) => {
|
||||
console.log(`Mode: ${(MULTI_DEVICE === 'false') ? 'No Multi-device' : 'Si Multi-device'} `)
|
||||
const objectLegacy = (login) ? {
|
||||
authStrategy: new LegacySessionAuth({
|
||||
session
|
||||
})
|
||||
} : {session};
|
||||
|
||||
if(MULTI_DEVICE == 'false') {
|
||||
return {...objectLegacy,
|
||||
restartOnAuthFail: true,
|
||||
puppeteer: {
|
||||
args: [
|
||||
'--no-sandbox'
|
||||
],
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return {
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox']
|
||||
},
|
||||
clientId: 'client-one'
|
||||
}
|
||||
}
|
||||
const createClient = () => {
|
||||
client = new Client({
|
||||
authStrategy: new LocalAuth(
|
||||
{dataPath: './sessions/',
|
||||
clientId: 'bot'}),
|
||||
puppeteer: { headless: false }
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
const isValidNumber = (rawNumber) => {
|
||||
|
||||
@@ -2,6 +2,7 @@ const fs = require('fs')
|
||||
const { sendMessage } = require('../controllers/send')
|
||||
|
||||
const sendMessagePost = (req, res) => {
|
||||
console.log('asdasdasdasdasd')
|
||||
const { message, number } = req.body
|
||||
const client = req.clientWs || null;
|
||||
sendMessage(client, number, message)
|
||||
|
||||
Reference in New Issue
Block a user