Correção da numeração automatica das sessões de whatsapp

pull/21/head
adriano 2023-04-10 17:50:02 -03:00
parent 0688bf34d4
commit c1a739395b
2 changed files with 8 additions and 3 deletions

View File

@ -29,7 +29,7 @@ app.post('/api/session', async function (req, res) {
console.log('__dirname: ', path.join(__dirname, '..', app_name)) console.log('__dirname: ', path.join(__dirname, '..', app_name))
console.log(app_name, whatsappId, client_url) console.log('app_name: ', app_name, ' | whatsappId: ', whatsappId, ' | client_url: ',client_url)
const sessionsPath = path.join(__dirname, '..', 'sessions') const sessionsPath = path.join(__dirname, '..', 'sessions')
@ -169,7 +169,7 @@ app.post('/api/session', async function (req, res) {
db = db[0].db_conf db = db[0].db_conf
} }
if (dirSessionsNumberAppDirectories.length > 0) { // if (dirSessionsNumberAppDirectories.length > 0) {
if (db && Object.keys(db).length > 0) { if (db && Object.keys(db).length > 0) {
@ -228,7 +228,7 @@ app.post('/api/session', async function (req, res) {
console.log('Number session: ', numberSession) console.log('Number session: ', numberSession)
} // }
dirSessionAppName = `${whatsappId}_${number}_${numberSession}_${appPort}` dirSessionAppName = `${whatsappId}_${number}_${numberSession}_${appPort}`
@ -436,6 +436,7 @@ process.on('uncaughtException', function (err) {
console.error(' '); console.error(' ');
return return
}); });
function deletePm2Process(process_name, currPath) { function deletePm2Process(process_name, currPath) {
pm2.connect(function (err) { pm2.connect(function (err) {
if (err) { if (err) {

View File

@ -21,6 +21,10 @@ const FormData = require('form-data');
// const { MessageMedia } = require('./node_modules/whatsapp-web.js/src/structures'); // const { MessageMedia } = require('./node_modules/whatsapp-web.js/src/structures');
let whatsappWebGlobalPath = path.join(process.env.NODE_PATH, 'whatsapp-web.js', '/src/structures'); let whatsappWebGlobalPath = path.join(process.env.NODE_PATH, 'whatsapp-web.js', '/src/structures');
whatsappWebGlobalPath = whatsappWebGlobalPath.replace(':','') whatsappWebGlobalPath = whatsappWebGlobalPath.replace(':','')
console.log('whatsappWebGlobalPath: ', whatsappWebGlobalPath)
console.log('process.env.NODE_PATH: ', process.env.NODE_PATH)
const { MessageMedia } = require(whatsappWebGlobalPath); const { MessageMedia } = require(whatsappWebGlobalPath);
const logger = require('logger') const logger = require('logger')