mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
✨ Adding multidevice whatsapp support
This commit is contained in:
@@ -42,14 +42,18 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||
if (whatsapp && whatsapp.session) {
|
||||
sessionCfg = JSON.parse(whatsapp.session);
|
||||
}
|
||||
|
||||
const wbot: Session = new Client({
|
||||
|
||||
const args:String = process.env.CHROME_ARGS || "";
|
||||
|
||||
const wbot: Session = new Client({
|
||||
session: sessionCfg,
|
||||
authStrategy: new LocalAuth({clientId: 'bd_'+whatsapp.id}),
|
||||
puppeteer: {
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||
executablePath: process.env.CHROME_BIN || undefined
|
||||
},
|
||||
puppeteer: {
|
||||
executablePath: process.env.CHROME_BIN || undefined,
|
||||
// @ts-ignore
|
||||
browserWSEndpoint: process.env.CHROME_WS || undefined,
|
||||
args: args.split(' ')
|
||||
}
|
||||
});
|
||||
|
||||
wbot.initialize();
|
||||
@@ -73,9 +77,6 @@ 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)
|
||||
// });
|
||||
});
|
||||
|
||||
wbot.on("auth_failure", async msg => {
|
||||
@@ -151,4 +152,4 @@ export const removeWbot = (whatsappId: number): void => {
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user