fix(whatsapp.gblib): SEND FILE and WPP providers.
This commit is contained in:
parent
08d8570af1
commit
3f7e024b58
1 changed files with 15 additions and 16 deletions
|
@ -138,7 +138,8 @@ export class WhatsappDirectLine extends GBService {
|
|||
const gbaiName = `${this.min.botId}.gbai`;
|
||||
const localName = Path.join('work', gbaiName, 'profile');
|
||||
|
||||
const createClient = (browserWSEndpoint) => {
|
||||
|
||||
const createClient = async (browserWSEndpoint) => {
|
||||
let puppeteer: any = {
|
||||
headless: false, args: ['--disable-features=site-per-process',
|
||||
`--user-data-dir=${localName}`]
|
||||
|
@ -155,7 +156,8 @@ export class WhatsappDirectLine extends GBService {
|
|||
puppeteer: puppeteer
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
await client.initialize();
|
||||
this.browserWSEndpoint = client.pupBrowser.wsEndpoint();
|
||||
|
||||
client.on('message', (async message => {
|
||||
await this.WhatsAppCallback(message, null);
|
||||
|
@ -196,16 +198,6 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
client.on('authenticated', () => {
|
||||
this.browserWSEndpoint = client.pupBrowser.wsEndpoint();
|
||||
|
||||
|
||||
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
|
||||
});
|
||||
};
|
||||
|
||||
client.pupBrowser.on('disconnected', (async () => {
|
||||
GBLog.info(`Browser crashed. Restarting ${this.min.botId} WhatsApp native provider.`);
|
||||
await (createClient.bind(this))(null);
|
||||
}).bind(this));
|
||||
client.pupPage.on('error', (async () => {
|
||||
GBLog.info(`Page crashed. Restarting ${this.min.botId} WhatsApp native provider.`);
|
||||
if (!client.pupPage.isClosed()){
|
||||
|
@ -213,7 +205,14 @@ export class WhatsappDirectLine extends GBService {
|
|||
} await (createClient.bind(this))(null);
|
||||
}).bind(this));
|
||||
|
||||
(createClient.bind(this))(this.browserWSEndpoint);
|
||||
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
|
||||
});
|
||||
client.pupBrowser.on('disconnected', (async () => {
|
||||
GBLog.info(`Browser crashed. Restarting ${this.min.botId} WhatsApp native provider.`);
|
||||
await (createClient.bind(this))(null);
|
||||
}).bind(this));
|
||||
};
|
||||
await (createClient.bind(this))(this.browserWSEndpoint);
|
||||
|
||||
|
||||
setUrl = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue