new(basic.gblib): Web Automation CAPTCHA processing.
This commit is contained in:
parent
100cf31250
commit
696e867364
4 changed files with 316 additions and 318 deletions
|
@ -670,27 +670,12 @@ export class DialogKeywords {
|
||||||
|
|
||||||
if (this.hrOn) {
|
if (this.hrOn) {
|
||||||
|
|
||||||
let sleep = ms => {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
setTimeout(resolve, ms);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Waits for next message in HEAR delegated context.
|
// Waits for next message in HEAR delegated context.
|
||||||
|
|
||||||
const mobile = await this.userMobile(step);
|
const botId = this.min.botId;
|
||||||
while (true) {
|
WhatsappDirectLine.state[botId + this.hrOn] = {
|
||||||
if (WhatsappDirectLine.state[mobile] === 3) {
|
promise: promise, previousResolve: previousResolve
|
||||||
break;
|
};
|
||||||
}
|
|
||||||
sleep(5000);
|
|
||||||
}
|
|
||||||
const result = WhatsappDirectLine.lastMessage[this.min.instance.botId + mobile];
|
|
||||||
opts = await promise(step, result);
|
|
||||||
|
|
||||||
if (previousResolve !== undefined) {
|
|
||||||
previousResolve(opts);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -729,8 +714,9 @@ export class DialogKeywords {
|
||||||
* Talks to the user by using the specified text.
|
* Talks to the user by using the specified text.
|
||||||
*/
|
*/
|
||||||
public async talk(step, text: string) {
|
public async talk(step, text: string) {
|
||||||
|
const translate = this.user ? this.user.basicOptions.translatorOn : false;
|
||||||
await this.min.conversationalService['sendTextWithOptions'](this.min, step, text,
|
await this.min.conversationalService['sendTextWithOptions'](this.min, step, text,
|
||||||
this.user.basicOptions.translatorOn, null);
|
translate, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getChannel(step): string {
|
private static getChannel(step): string {
|
||||||
|
|
|
@ -175,8 +175,8 @@ export class GBVMService extends GBService {
|
||||||
code = `<%\n
|
code = `<%\n
|
||||||
|
|
||||||
id = sys().getRandomId()
|
id = sys().getRandomId()
|
||||||
username = this.userName(step);
|
username = step ? this.userName(step) : sys().getRandomId();
|
||||||
mobile = this.userMobile(step);
|
mobile = step ? this.userMobile(step) : sys().getRandomId();
|
||||||
from = mobile;
|
from = mobile;
|
||||||
ubound = function(array){return array.length};
|
ubound = function(array){return array.length};
|
||||||
isarray = function(array){return Array.isArray(array) };
|
isarray = function(array){return Array.isArray(array) };
|
||||||
|
@ -728,7 +728,7 @@ export class GBVMService extends GBService {
|
||||||
GBConfigService.get('DEFAULT_CONTENT_LANGUAGE')
|
GBConfigService.get('DEFAULT_CONTENT_LANGUAGE')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (step.context.activity['originalText']) {
|
if (step && step.context.activity['originalText']) {
|
||||||
const entities = await min["nerEngine"].findEntities(
|
const entities = await min["nerEngine"].findEntities(
|
||||||
step.context.activity['originalText'],
|
step.context.activity['originalText'],
|
||||||
contentLocale);
|
contentLocale);
|
||||||
|
|
|
@ -188,8 +188,6 @@ export class GBMinService {
|
||||||
});
|
});
|
||||||
|
|
||||||
GBLog.info(`Package deployment done.`);
|
GBLog.info(`Package deployment done.`);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -524,7 +522,7 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
GBLog.error(`Error on Whatsapp callback: ${error.data ? error.data : error}`);
|
GBLog.error(`Error on Whatsapp callback: ${error.data ? error.data : error} ${error.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,6 +1247,8 @@ export class GBMinService {
|
||||||
|
|
||||||
} else if (cmdOrDialogName === '/call') {
|
} else if (cmdOrDialogName === '/call') {
|
||||||
await GBVMService.callVM(args, min, step, this.deployer);
|
await GBVMService.callVM(args, min, step, this.deployer);
|
||||||
|
} else if (cmdOrDialogName === '/callsch') {
|
||||||
|
await GBVMService.callVM(args, min, null, null);
|
||||||
} else {
|
} else {
|
||||||
await step.beginDialog(cmdOrDialogName, { args: args });
|
await step.beginDialog(cmdOrDialogName, { args: args });
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,6 +278,18 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const botId = this.min.instance.botId;
|
||||||
|
|
||||||
|
const state = WhatsappDirectLine.state[botId + from];
|
||||||
|
if ( state) {
|
||||||
|
WhatsappDirectLine.state[botId + from] = null;
|
||||||
|
await state.promise(null, message.text);
|
||||||
|
|
||||||
|
return; // Exit here.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Processes .gbapp message interception.
|
||||||
|
|
||||||
await CollectionUtil.asyncForEach(this.min.appPackages, async (e: IGBPackage) => {
|
await CollectionUtil.asyncForEach(this.min.appPackages, async (e: IGBPackage) => {
|
||||||
await e.onExchangeData(this.min, 'whatsappMessage', message);
|
await e.onExchangeData(this.min, 'whatsappMessage', message);
|
||||||
|
@ -291,7 +303,9 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
if (answerText) {
|
if (answerText) {
|
||||||
await this.sendToDeviceEx(user.userSystemId, answerText, locale, null);
|
await this.sendToDeviceEx(user.userSystemId, answerText, locale, null);
|
||||||
|
|
||||||
return; // Exit here.
|
return; // Exit here.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.type === 'ptt') {
|
if (message.type === 'ptt') {
|
||||||
|
@ -315,14 +329,12 @@ export class WhatsappDirectLine extends GBService {
|
||||||
`No momento estou apenas conseguindo ler mensagens de texto.`, null);
|
`No momento estou apenas conseguindo ler mensagens de texto.`, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const botId = this.min.instance.botId;
|
|
||||||
const conversationId = WhatsappDirectLine.conversationIds[botId + from + group];
|
const conversationId = WhatsappDirectLine.conversationIds[botId + from + group];
|
||||||
|
|
||||||
const client = await this.directLineClient;
|
const client = await this.directLineClient;
|
||||||
|
|
||||||
WhatsappDirectLine.lastMessage[botId + from] = message;
|
WhatsappDirectLine.lastMessage[botId + from] = message;
|
||||||
|
|
||||||
|
|
||||||
// Check if this message is from a Human Agent itself.
|
// Check if this message is from a Human Agent itself.
|
||||||
|
|
||||||
if (user.agentMode === 'self') {
|
if (user.agentMode === 'self') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue