fix(basic.gblib): update ChatServices.ts #420

Closed
eltociear wants to merge 2540 commits from patch-1 into main
Showing only changes of commit 1d6ecfb9bc - Show all commits

View file

@ -139,21 +139,18 @@ export class WhatsappDirectLine extends GBService {
const localName = Path.join('work', gbaiName, 'profile');
const browser = await createBrowser(localName);
const createClient = (browserWSEndpoint)=>{
const client = this.customClient = new Client({
authStrategy: new LocalAuth({
clientId: this.min.botId,
dataPath: localName
}),
puppeteer: browser
puppeteer: {browserWSEndpoint:browserWSEndpoint }
});
client.initialize();
this.browserWSEndpoint = browser.wsEndpoint(); // store for later
browser.on('disconnected', (async () => {
client.browser = await puppeteer.connect({browserWSEndpoint: this.browserWSEndpoint});
}).bind(this));
// Dispatches messages to the received method.
client.on('message', (async message => {
await this.WhatsAppCallback(message, null);
@ -196,6 +193,17 @@ export class WhatsappDirectLine extends GBService {
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
});
};
this.browserWSEndpoint = browser.wsEndpoint(); // store for later
(createClient.bind(this))(this.browserWSEndpoint);
browser.on('disconnected', (async () => {
(createClient.bind(this))(this.browserWSEndpoint);
}).bind(this));
setUrl = false;
}
break;