mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-19 12:09:15 +00:00
se agego multi-device .env
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
const { Client, LegacySessionAuth, LocalAuth } = require('whatsapp-web.js');
|
||||
const http = require('http'); // or 'https' for https:// URLs
|
||||
const https = require('https'); // or 'https' for https:// URLs
|
||||
const fs = require('fs');
|
||||
const qr = require('qr-image')
|
||||
|
||||
const MULTI_DEVICE = process.env.MULTI_DEVICE || 'false';
|
||||
|
||||
const cleanNumber = (number) => {
|
||||
number = number.replace('@c.us', '');
|
||||
@@ -57,4 +59,37 @@ const checkEnvFile = () => {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl, 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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl, checkEnvFile, createClient}
|
||||
Reference in New Issue
Block a user