Merge branch 'main' of https://github.com/GeneralBots/BotServer
This commit is contained in:
commit
39f1907291
4 changed files with 32 additions and 15 deletions
|
@ -11,7 +11,8 @@
|
|||
"João Ferreira <joao.parana@gmail.com>",
|
||||
"Jorge Ramos <jramos@pobox.com>",
|
||||
"PH <ph.an@outlook.com>",
|
||||
"Dário Vieira <dario.junior3@gmail.com>"
|
||||
"Dário Vieira <dario.junior3@gmail.com>",
|
||||
"Alan Perdomo <alanperdomo@hotmail.com>"
|
||||
],
|
||||
"engines": {
|
||||
"node": "=19.7.0"
|
||||
|
@ -143,6 +144,7 @@
|
|||
"puppeteer-extra": "3.3.4",
|
||||
"puppeteer-extra-plugin-stealth": "2.11.1",
|
||||
"qrcode": "1.5.1",
|
||||
"qr-scanner": "^1.4.2",
|
||||
"qrcode-terminal": "0.12.0",
|
||||
"readline": "1.3.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
|
|
|
@ -59,6 +59,7 @@ import qrcode from 'qrcode';
|
|||
import { json } from 'body-parser';
|
||||
import { WebAutomationServices } from './WebAutomationServices.js';
|
||||
import urljoin from 'url-join';
|
||||
import QrScanner from 'qr-scanner';
|
||||
|
||||
/**
|
||||
* Default check interval for user replay
|
||||
|
@ -205,28 +206,28 @@ export class DialogKeywords {
|
|||
*
|
||||
* @example EXIT
|
||||
*/
|
||||
public async exit({}) {}
|
||||
public async exit({ }) { }
|
||||
|
||||
/**
|
||||
* Get active tasks.
|
||||
*
|
||||
* @example list = ACTIVE TASKS
|
||||
*/
|
||||
public async getActiveTasks({ pid }) {}
|
||||
public async getActiveTasks({ pid }) { }
|
||||
|
||||
/**
|
||||
* Creates a new deal.
|
||||
*
|
||||
* @example CREATE DEAL dealname,contato,empresa,amount
|
||||
*/
|
||||
public async createDeal({ pid, dealName, contact, company, amount }) {}
|
||||
public async createDeal({ pid, dealName, contact, company, amount }) { }
|
||||
|
||||
/**
|
||||
* Finds contacts in XRM.
|
||||
*
|
||||
* @example list = FIND CONTACT "Sandra"
|
||||
*/
|
||||
public async fndContact({ pid, name }) {}
|
||||
public async fndContact({ pid, name }) { }
|
||||
|
||||
public getContentLocaleWithCulture(contentLocale) {
|
||||
switch (contentLocale) {
|
||||
|
@ -668,7 +669,7 @@ export class DialogKeywords {
|
|||
* @example MENU
|
||||
*
|
||||
*/
|
||||
public async showMenu({}) {
|
||||
public async showMenu({ }) {
|
||||
// https://github.com/GeneralBots/BotServer/issues/237
|
||||
// return await beginDialog('/menu');
|
||||
}
|
||||
|
@ -771,7 +772,7 @@ export class DialogKeywords {
|
|||
const answer = min.cbMap[userId].promise;
|
||||
|
||||
if (kind === 'sheet') {
|
||||
|
||||
|
||||
// Retrieves the .xlsx file associated with the HEAR var AS file.xlsx.
|
||||
|
||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||
|
@ -807,12 +808,11 @@ export class DialogKeywords {
|
|||
let list = [];
|
||||
for (; index < results.text.length; index++) {
|
||||
if (results.text[index][0] !== '') {
|
||||
list.push( results.text[index][0]);
|
||||
list.push(results.text[index][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search the answer in one of valid list items loaded from sheeet.
|
||||
|
@ -945,6 +945,13 @@ export class DialogKeywords {
|
|||
}
|
||||
|
||||
result = phoneNumber;
|
||||
} else if (kind === 'qr-scanner'){
|
||||
//https://github.com/GeneralBots/BotServer/issues/171
|
||||
GBLog.info(`BASIC (${min.botId}): Upload done for ${answer.filename}.`);
|
||||
const handle = WebAutomationServices.cyrb53(this.min.botId + answer.filename);
|
||||
GBServer.globals.files[handle] = answer;
|
||||
QrScanner.scanImage(GBServer.globals.files[handle]).then(result => console.log(result)).catch(error => console.log(error || 'no QR code found.'));
|
||||
|
||||
} else if (kind === 'zipcode') {
|
||||
const extractEntity = (text: string) => {
|
||||
text = text.replace(/\-/gi, '');
|
||||
|
@ -1074,6 +1081,7 @@ export class DialogKeywords {
|
|||
|
||||
await min.conversationalService['sendOnConversation'](min, user, text);
|
||||
}
|
||||
return { status: 0 };
|
||||
}
|
||||
|
||||
private static getChannel(): string {
|
||||
|
|
|
@ -139,7 +139,7 @@ export class KeywordsExpressions {
|
|||
/^\s*open\s*(.*)/gim,
|
||||
($0, $1, $2) => {
|
||||
let sessionName;
|
||||
let kind = '';
|
||||
let kind = null;
|
||||
let pos;
|
||||
|
||||
if (pos = $1.match(/\s*AS\s*\#/)) {
|
||||
|
@ -247,6 +247,13 @@ export class KeywordsExpressions {
|
|||
}
|
||||
];
|
||||
|
||||
keywords[i++] = [
|
||||
/^\s*hear (\w+) as\s*qrcode/gim,
|
||||
($0, $1) => {
|
||||
return `${$1} = await dk.getHear({pid: pid, kind:"qrcode")}`;
|
||||
}
|
||||
];
|
||||
|
||||
keywords[i++] = [
|
||||
/^\s*hear (\w+) as\s*language/gim,
|
||||
($0, $1) => {
|
||||
|
@ -655,7 +662,7 @@ export class KeywordsExpressions {
|
|||
// page is not string.
|
||||
// https://github.com/GeneralBots/BotServer/issues/310
|
||||
const params = this.getParams('page,' + $3, ['handle', 'frameOrSelector', 'selector']);
|
||||
return `await wa.click ({pid: pid, ${params}})`;
|
||||
return `await wa.getClick ({pid: pid, ${params}})`;
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -764,7 +771,7 @@ export class KeywordsExpressions {
|
|||
/^\s*set\s*(.*)/gim,
|
||||
($0, $1, $2) => {
|
||||
const params = this.getParams($1, ['file', 'address', 'value']);
|
||||
return `await sys.set ({pid: pid, ${params}})`;
|
||||
return `await sys.getSet ({pid: pid, handle:page, ${params}})`;
|
||||
}
|
||||
];
|
||||
keywords[i++] = [
|
||||
|
|
|
@ -245,7 +245,7 @@ export class WebAutomationServices {
|
|||
*
|
||||
* @example CLICK page,"#idElement"
|
||||
*/
|
||||
public async click({ pid, handle, frameOrSelector, selector }) {
|
||||
public async getClick({ pid, handle, frameOrSelector, selector }) {
|
||||
const page = this.getPageByHandle(handle);
|
||||
GBLog.info(`BASIC: Web Automation CLICK element: ${frameOrSelector}.`);
|
||||
if (selector) {
|
||||
|
|
Loading…
Add table
Reference in a new issue