new(all): Custom Domain support per bot.

This commit is contained in:
rodrigorodriguez 2022-10-09 20:46:17 -03:00
parent dfd89ec5e7
commit cda4959501
3 changed files with 38 additions and 5 deletions

View file

@ -85,6 +85,9 @@ export class DialogKeywords {
step: GBDialogStep;
debugWeb: boolean;
lastDebugWeb: Date;
/**
* SYSTEM account maxLines, when used with impersonated contexts (eg. running in SET SCHEDULE).
*/
@ -112,6 +115,13 @@ export class DialogKeywords {
this.user = user;
this.internalSys = new SystemKeywords(min, deployer, this);
this.step = step;
this.debugWeb = this.min.core.getParam<boolean>(
this.min.instance,
'Debug Web Automation',
false
);
}
/**
@ -276,17 +286,18 @@ export class DialogKeywords {
/**
* Simulates a mouse hover an web page element.
*/
*/
public async hover(step, page, idOrName) {
GBLog.info(`BASIC: Web Automation HOVER element: ${idOrName}.`);
await this.getBySelector(page, idOrName);
await page.hover(idOrName);
await this.debugStepWeb(page);
}
/**
* Clicks on an element in a web page.
*
* @example x = TODAY
* @example CLICK page, "#idElement"
*/
public async click(step, page, frameOrSelector, selector) {
GBLog.info(`BASIC: Web Automation CLICK element: ${frameOrSelector}.`);
@ -301,6 +312,22 @@ export class DialogKeywords {
await page.waitForSelector(frameOrSelector);
await page.click(frameOrSelector);
}
await this.debugStepWeb(page);
}
private async debugStepWeb(page) {
let refresh = false;
if (this.lastDebugWeb)
{
refresh = (new Date().getTime() - this.lastDebugWeb.getTime()) > 5000;
}
if (this.debugWeb && refresh) {
const adminNumber = this.min.core.getParam(this.min.instance, 'Bot Admin Number', null);
await this.sendFileTo(this.step, adminNumber, page, "General Bots Debugger");
this.lastDebugWeb = new Date();
}
}
/**
@ -331,6 +358,7 @@ export class DialogKeywords {
}
const els = await page.$x(`//a[contains(., '${text}')]`);
await els[index - 1].click();
await this.debugStepWeb(page);
}
@ -369,6 +397,7 @@ export class DialogKeywords {
GBLog.info(`BASIC: Web Automation TYPE on ${idOrName}: ${text}.`);
const e = await this.getBySelector(page, idOrName);
await e.type(text, { delay: 200 });
await this.debugStepWeb(page);
}
/**

View file

@ -194,6 +194,9 @@ export class GBVMService extends GBService {
${process.env.ENABLE_AUTH ? `hear gbLogin as login` : ``}
${code}
`;
// Keywords from General Bots BASIC.

View file

@ -212,7 +212,7 @@ export class WhatsappDirectLine extends GBService {
await (createClient.bind(this))(null);
}).bind(this));
GBLog.info(`GBWhatsApp: Empty chat list for ${this.botId}GBWhatsApp:...`);
GBLog.info(`GBWhatsApp: Emptying chat list for ${this.botId}...`);
// Keeps the chat list cleaned.
@ -304,8 +304,9 @@ export class WhatsappDirectLine extends GBService {
switch (this.provider) {
case 'GeneralBots':
const info = await this.customClient.getState();
GBLog.info(`GBWhatsapp: ${info.WAState}.`);
break;
return info == "CONNECTED";
default:
const options = {
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}`,