new(all): Custom Domain support per bot.
This commit is contained in:
parent
dfd89ec5e7
commit
cda4959501
3 changed files with 38 additions and 5 deletions
|
@ -85,6 +85,9 @@ export class DialogKeywords {
|
||||||
|
|
||||||
step: GBDialogStep;
|
step: GBDialogStep;
|
||||||
|
|
||||||
|
debugWeb: boolean;
|
||||||
|
lastDebugWeb: Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SYSTEM account maxLines, when used with impersonated contexts (eg. running in SET SCHEDULE).
|
* SYSTEM account maxLines, when used with impersonated contexts (eg. running in SET SCHEDULE).
|
||||||
*/
|
*/
|
||||||
|
@ -112,6 +115,13 @@ export class DialogKeywords {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.internalSys = new SystemKeywords(min, deployer, this);
|
this.internalSys = new SystemKeywords(min, deployer, this);
|
||||||
this.step = step;
|
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.
|
* Simulates a mouse hover an web page element.
|
||||||
*/
|
*/
|
||||||
public async hover(step, page, idOrName) {
|
public async hover(step, page, idOrName) {
|
||||||
GBLog.info(`BASIC: Web Automation HOVER element: ${idOrName}.`);
|
GBLog.info(`BASIC: Web Automation HOVER element: ${idOrName}.`);
|
||||||
await this.getBySelector(page, idOrName);
|
await this.getBySelector(page, idOrName);
|
||||||
await page.hover(idOrName);
|
await page.hover(idOrName);
|
||||||
|
await this.debugStepWeb(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clicks on an element in a web page.
|
* Clicks on an element in a web page.
|
||||||
*
|
*
|
||||||
* @example x = TODAY
|
* @example CLICK page, "#idElement"
|
||||||
*/
|
*/
|
||||||
public async click(step, page, frameOrSelector, selector) {
|
public async click(step, page, frameOrSelector, selector) {
|
||||||
GBLog.info(`BASIC: Web Automation CLICK element: ${frameOrSelector}.`);
|
GBLog.info(`BASIC: Web Automation CLICK element: ${frameOrSelector}.`);
|
||||||
|
@ -301,6 +312,22 @@ export class DialogKeywords {
|
||||||
await page.waitForSelector(frameOrSelector);
|
await page.waitForSelector(frameOrSelector);
|
||||||
await page.click(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}')]`);
|
const els = await page.$x(`//a[contains(., '${text}')]`);
|
||||||
await els[index - 1].click();
|
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}.`);
|
GBLog.info(`BASIC: Web Automation TYPE on ${idOrName}: ${text}.`);
|
||||||
const e = await this.getBySelector(page, idOrName);
|
const e = await this.getBySelector(page, idOrName);
|
||||||
await e.type(text, { delay: 200 });
|
await e.type(text, { delay: 200 });
|
||||||
|
await this.debugStepWeb(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -194,6 +194,9 @@ export class GBVMService extends GBService {
|
||||||
${process.env.ENABLE_AUTH ? `hear gbLogin as login` : ``}
|
${process.env.ENABLE_AUTH ? `hear gbLogin as login` : ``}
|
||||||
|
|
||||||
${code}
|
${code}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Keywords from General Bots BASIC.
|
// Keywords from General Bots BASIC.
|
||||||
|
|
|
@ -212,7 +212,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
await (createClient.bind(this))(null);
|
await (createClient.bind(this))(null);
|
||||||
}).bind(this));
|
}).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.
|
// Keeps the chat list cleaned.
|
||||||
|
|
||||||
|
@ -304,8 +304,9 @@ export class WhatsappDirectLine extends GBService {
|
||||||
switch (this.provider) {
|
switch (this.provider) {
|
||||||
case 'GeneralBots':
|
case 'GeneralBots':
|
||||||
const info = await this.customClient.getState();
|
const info = await this.customClient.getState();
|
||||||
GBLog.info(`GBWhatsapp: ${info.WAState}.`);
|
|
||||||
break;
|
return info == "CONNECTED";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
const options = {
|
const options = {
|
||||||
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}`,
|
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}`,
|
||||||
|
|
Loading…
Add table
Reference in a new issue