new(whatsapp.gblib): Native provider works in groups now.

This commit is contained in:
rodrigorodriguez 2022-10-13 11:24:21 -03:00
parent 34414f65ac
commit f0b996fd68
2 changed files with 18 additions and 14 deletions

View file

@ -870,7 +870,7 @@ export class GBVMService extends GBService {
} }
} catch (error) { } catch (error) {
throw new Error(`BASIC ERROR: ${error.message ? error.message : error}\n Stack:${error.stack}`); throw new Error(`BASIC RUNTIME ERR: ${error.message ? error.message : error}\n Stack:${error.stack}`);
} }
return ret; return ret;
} }

View file

@ -150,7 +150,7 @@ export class WhatsappDirectLine extends GBService {
const browser = await createBrowser(profilePath); const browser = await createBrowser(profilePath);
this.browserWSEndpoint = await browser.wsEndpoint(); this.browserWSEndpoint = await browser.wsEndpoint();
} }
else{ else {
this.browserWSEndpoint = browserWSEndpoint; this.browserWSEndpoint = browserWSEndpoint;
} }
@ -179,19 +179,23 @@ export class WhatsappDirectLine extends GBService {
qrcode.generate(qr, { small: true, scale: 0.5 }); qrcode.generate(qr, { small: true, scale: 0.5 });
// While handling other bots uses boot instance of this class to send QR Codes. // While handling other bots uses boot instance of this class to send QR Codes.
const s = new DialogKeywords(this.min, null, null, null); const s = new DialogKeywords(this.min, null, null, null);
const qrBuf = await s.getQRCode(qr); if (minBoot.botId !== this.botId) {
const gbaiName = `${this.min.botId}.gbai`; const qrBuf = await s.getQRCode(qr);
const localName = Path.join('work', gbaiName, 'cache', `qr${GBAdminService.getRndReadableIdentifier()}.png`); const gbaiName = `${this.min.botId}.gbai`;
fs.writeFileSync(localName, qrBuf); const localName = Path.join('work', gbaiName, 'cache', `qr${GBAdminService.getRndReadableIdentifier()}.png`);
const url = urlJoin( fs.writeFileSync(localName, qrBuf);
GBServer.globals.publicAddress, const url = urlJoin(
this.min.botId, GBServer.globals.publicAddress,
'cache', this.min.botId,
Path.basename(localName) 'cache',
); Path.basename(localName)
GBServer.globals.minBoot.whatsAppDirectLine.sendFileToDevice(adminNumber, url, Path.basename(localName), msg); );
GBServer.globals.minBoot.whatsAppDirectLine.sendFileToDevice(adminNumber, url, Path.basename(localName), msg);
}
// The e-mail is sent to all bots.
s.sendEmail(adminEmail, `Check your WhatsApp for bot ${this.botId}`, msg); s.sendEmail(adminEmail, `Check your WhatsApp for bot ${this.botId}`, msg);
}).bind(this)); }).bind(this));