mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-17 19:37:02 +00:00
Merge pull request #432 from Kouthk/patch-2
🔨configuração para utilizar whatsapp multi-device
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import qrCode from "qrcode-terminal";
|
import qrCode from "qrcode-terminal";
|
||||||
import { Client } from "whatsapp-web.js";
|
import { Client, LocalAuth } from "whatsapp-web.js";
|
||||||
import { getIO } from "./socket";
|
import { getIO } from "./socket";
|
||||||
import Whatsapp from "../models/Whatsapp";
|
import Whatsapp from "../models/Whatsapp";
|
||||||
import AppError from "../errors/AppError";
|
import AppError from "../errors/AppError";
|
||||||
@@ -42,17 +42,14 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
|||||||
if (whatsapp && whatsapp.session) {
|
if (whatsapp && whatsapp.session) {
|
||||||
sessionCfg = JSON.parse(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,
|
session: sessionCfg,
|
||||||
puppeteer: {
|
authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}),
|
||||||
executablePath: process.env.CHROME_BIN || undefined,
|
puppeteer: {
|
||||||
// @ts-ignore
|
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||||
browserWSEndpoint: process.env.CHROME_WS || undefined,
|
executablePath: process.env.CHROME_BIN || undefined
|
||||||
args: args.split(' ')
|
},
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
wbot.initialize();
|
wbot.initialize();
|
||||||
@@ -76,9 +73,9 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
|||||||
|
|
||||||
wbot.on("authenticated", async session => {
|
wbot.on("authenticated", async session => {
|
||||||
logger.info(`Session: ${sessionName} AUTHENTICATED`);
|
logger.info(`Session: ${sessionName} AUTHENTICATED`);
|
||||||
await whatsapp.update({
|
// await whatsapp.update({
|
||||||
session: JSON.stringify(session)
|
// session: JSON.stringify(session)
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
wbot.on("auth_failure", async msg => {
|
wbot.on("auth_failure", async msg => {
|
||||||
|
|||||||
Reference in New Issue
Block a user