mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-17 19:37:02 +00:00
🔨configuração para utilizar whatsapp multi-device
Quem fez essa modificação foi o @w3nder .
Estou apenas colando do repositorio pessoal dele e solicitando o Merge aqui.
Ele deu autorização para que eu pudesse fazer isso, todos os creditos são dele.
arquivo original: bfa935ada3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import qrCode from "qrcode-terminal";
|
||||
import { Client } from "whatsapp-web.js";
|
||||
import { Client, LocalAuth } from "whatsapp-web.js";
|
||||
import { getIO } from "./socket";
|
||||
import Whatsapp from "../models/Whatsapp";
|
||||
import AppError from "../errors/AppError";
|
||||
@@ -42,17 +42,14 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||
if (whatsapp && whatsapp.session) {
|
||||
sessionCfg = JSON.parse(whatsapp.session);
|
||||
}
|
||||
|
||||
const args:String = process.env.CHROME_ARGS || "";
|
||||
|
||||
const wbot: Session = new Client({
|
||||
|
||||
const wbot: Session = new Client({
|
||||
session: sessionCfg,
|
||||
puppeteer: {
|
||||
executablePath: process.env.CHROME_BIN || undefined,
|
||||
// @ts-ignore
|
||||
browserWSEndpoint: process.env.CHROME_WS || undefined,
|
||||
args: args.split(' ')
|
||||
}
|
||||
authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}),
|
||||
puppeteer: {
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||
executablePath: process.env.CHROME_BIN || undefined
|
||||
},
|
||||
});
|
||||
|
||||
wbot.initialize();
|
||||
@@ -76,9 +73,9 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||
|
||||
wbot.on("authenticated", async session => {
|
||||
logger.info(`Session: ${sessionName} AUTHENTICATED`);
|
||||
await whatsapp.update({
|
||||
session: JSON.stringify(session)
|
||||
});
|
||||
// await whatsapp.update({
|
||||
// session: JSON.stringify(session)
|
||||
// });
|
||||
});
|
||||
|
||||
wbot.on("auth_failure", async msg => {
|
||||
|
||||
Reference in New Issue
Block a user