This commit is contained in:
Alan Perdomo 2022-12-29 14:47:26 -03:00
commit 943644313d
24 changed files with 131 additions and 43448 deletions

3
.gitignore vendored
View file

@ -11,6 +11,8 @@
/packages/default.gbui/build /packages/default.gbui/build
/packages/default.gbui/.env /packages/default.gbui/.env
/packages/default.gbui/node_modules /packages/default.gbui/node_modules
/packages/default.gbui/package-lock.json
/packages/default.gbui/yarn-lock.json
/work /work
*.vbs.compiled *.vbs.compiled
*.vbs.js *.vbs.js
@ -24,3 +26,4 @@ gb.log
GB.log.json GB.log.json
yarn-error.log yarn-error.log
package-lock.json package-lock.json
yarn-lock.json

View file

@ -12,7 +12,7 @@ before_script:
branches: branches:
only: only:
- master - main
- /^greenkeeper/.*$/ - /^greenkeeper/.*$/
except: except:
- /^v\d+\.\d+\.\d+$/ - /^v\d+\.\d+\.\d+$/

View file

@ -1,3 +1,25 @@
# [2.1.0](https://github.com/GeneralBots/BotServer/compare/2.0.182...2.1.0) (2022-12-23)
### Features
* **all:** Cleaning package manager files. ([0cb406a](https://github.com/GeneralBots/BotServer/commit/0cb406ab7923761ad7476ef694d5079af059244c))
* **all:** Token retrieve optimized. ([6eb9d6c](https://github.com/GeneralBots/BotServer/commit/6eb9d6cbf466a18283285d6775e08aa488632762))
## [2.0.182](https://github.com/GeneralBots/BotServer/compare/2.0.181...2.0.182) (2022-12-23)
### Bug Fixes
* **all:** Node version info retrieval automated. ([9cbd8c1](https://github.com/GeneralBots/BotServer/commit/9cbd8c17de674547ed24a189084e8b99588ac69b))
## [2.0.181](https://github.com/GeneralBots/BotServer/compare/2.0.180...2.0.181) (2022-12-22)
### Bug Fixes
* **admin.gbapp:** .gbapp List param added to .gbot. ([48a1aa4](https://github.com/GeneralBots/BotServer/commit/48a1aa4d4695b480b6724f6c59830cfe3fa45f8c))
## [2.0.180](https://github.com/GeneralBots/BotServer/compare/2.0.179...2.0.180) (2022-12-16) ## [2.0.180](https://github.com/GeneralBots/BotServer/compare/2.0.179...2.0.180) (2022-12-16)

View file

@ -1,6 +1,6 @@
{ {
"name": "botserver", "name": "botserver",
"version": "2.0.180", "version": "2.1.0",
"type": "module", "type": "module",
"description": "General Bot Community Edition open-core server.", "description": "General Bot Community Edition open-core server.",
"main": "./boot.mjs", "main": "./boot.mjs",
@ -14,7 +14,7 @@
"Dário Vieira <dario.junior3@gmail.com>" "Dário Vieira <dario.junior3@gmail.com>"
], ],
"engines": { "engines": {
"node": "=19.2.0" "node": "=19.3.0"
}, },
"license": "AGPL-3.0", "license": "AGPL-3.0",
"preferGlobal": true, "preferGlobal": true,
@ -85,7 +85,7 @@
"botbuilder-ai": "4.18.0", "botbuilder-ai": "4.18.0",
"botbuilder-dialogs": "4.18.0", "botbuilder-dialogs": "4.18.0",
"botframework-connector": "4.18.0", "botframework-connector": "4.18.0",
"botlib": "3.0.0", "botlib": "3.0.2",
"c3-chart-maker": "0.2.8", "c3-chart-maker": "0.2.8",
"chatgpt": "2.4.2", "chatgpt": "2.4.2",
"chrome-remote-interface": "0.31.3", "chrome-remote-interface": "0.31.3",

View file

@ -50,11 +50,11 @@ import { CollectionUtil } from 'pragmatismo-io-framework';
* Dialogs for administration tasks. * Dialogs for administration tasks.
*/ */
export class AdminDialog extends IGBDialog { export class AdminDialog extends IGBDialog {
public static isIntentYes (locale, utterance) { public static isIntentYes(locale, utterance) {
return utterance.toLowerCase().match(Messages[locale].affirmative_sentences); return utterance.toLowerCase().match(Messages[locale].affirmative_sentences);
} }
public static isIntentNo (locale, utterance) { public static isIntentNo(locale, utterance) {
return utterance.toLowerCase().match(Messages[locale].negative_sentences); return utterance.toLowerCase().match(Messages[locale].negative_sentences);
} }
@ -64,7 +64,7 @@ export class AdminDialog extends IGBDialog {
* @param bot The bot adapter. * @param bot The bot adapter.
* @param min The minimal bot instance data. * @param min The minimal bot instance data.
*/ */
public static setup (min: GBMinInstance) { public static setup(min: GBMinInstance) {
// Setup services. // Setup services.
const importer = new GBImporter(min.core); const importer = new GBImporter(min.core);
@ -217,12 +217,19 @@ export class AdminDialog extends IGBDialog {
// If the user says yes, starts publishing. // If the user says yes, starts publishing.
if (AdminDialog.isIntentYes(locale, step.result)) { if (AdminDialog.isIntentYes(locale, step.result)) {
const list = min.core.getParam(min.instance, '.gbapp List', null);
const items = list ? list.split(';') : [];
step.activeDialog.state.options.args; step.activeDialog.state.options.args;
for (let index = 0; index < min.appPackages.length; index++) { for (let i = 0; i < items.length; i++) {
const element = min.appPackages[index]; for (let j = 0; j < min.appPackages.length; j++) {
if (items[i] === min.appPackages[j]['name']) {
const element = min.appPackages[i];
await element.onExchangeData(min, 'install', null); await element.onExchangeData(min, 'install', null);
// TODO: Filter just to the .gbapp being installed. break;
}
}
} }
} else { } else {
await min.conversationalService.sendText(min, step, Messages[locale].publish_canceled); await min.conversationalService.sendText(min, step, Messages[locale].publish_canceled);
@ -308,9 +315,7 @@ export class AdminDialog extends IGBDialog {
try { try {
let cmd1; let cmd1;
if (packageName.indexOf('.') !== -1) { if (packageName.indexOf('.') !== -1) {
cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${ cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${process.env.STORAGE_LIBRARY}/${botId}.gbai/${packageName}`;
process.env.STORAGE_LIBRARY
}/${botId}.gbai/${packageName}`;
} else { } else {
cmd1 = `deployPackage ${packageName}`; cmd1 = `deployPackage ${packageName}`;
} }
@ -348,7 +353,7 @@ export class AdminDialog extends IGBDialog {
* the /broadcast command with specific phone numbers. * the /broadcast command with specific phone numbers.
* @param phone Phone number to check (eg.: +5521900002233) * @param phone Phone number to check (eg.: +5521900002233)
*/ */
public static canPublish (min: GBMinInstance, phone: string): Boolean { public static canPublish(min: GBMinInstance, phone: string): Boolean {
if (process.env.SECURITY_CAN_PUBLISH !== undefined) { if (process.env.SECURITY_CAN_PUBLISH !== undefined) {
let list = process.env.SECURITY_CAN_PUBLISH.split(';'); let list = process.env.SECURITY_CAN_PUBLISH.split(';');
@ -361,13 +366,15 @@ export class AdminDialog extends IGBDialog {
if (!result && min.instance.params) { if (!result && min.instance.params) {
const params = JSON.parse(min.instance.params); const params = JSON.parse(min.instance.params);
if (params){
return list.includes(params['Can Publish']); return list.includes(params['Can Publish']);
} }
}
return result; return result;
} }
} }
private static setupSecurityDialogs (min: GBMinInstance) { private static setupSecurityDialogs(min: GBMinInstance) {
min.dialogs.add( min.dialogs.add(
new WaterfallDialog('/setupSecurity', [ new WaterfallDialog('/setupSecurity', [
async step => { async step => {
@ -410,11 +417,7 @@ export class AdminDialog extends IGBDialog {
min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state); min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
const redirectUri = urlJoin(min.instance.botEndpoint, min.instance.botId, '/token'); const redirectUri = urlJoin(min.instance.botEndpoint, min.instance.botId, '/token');
const url = `https://login.microsoftonline.com/${ const url = `https://login.microsoftonline.com/${step.activeDialog.state.authenticatorTenant}/oauth2/authorize?client_id=${min.instance.marketplaceId}&response_type=code&redirect_uri=${redirectUri}&scope=https://graph.microsoft.com/.default&state=${state}&response_mode=query`;
step.activeDialog.state.authenticatorTenant
}/oauth2/authorize?client_id=${
min.instance.marketplaceId
}&response_type=code&redirect_uri=${redirectUri}&scope=https://graph.microsoft.com/.default&state=${state}&response_mode=query`;
await min.conversationalService.sendText(min, step, Messages[locale].consent(url)); await min.conversationalService.sendText(min, step, Messages[locale].consent(url));

View file

@ -51,6 +51,8 @@ import msRestAzure from 'ms-rest-azure';
import Path from 'path'; import Path from 'path';
import {caseSensitive_Numbs_SpecialCharacters_PW} from 'super-strong-password-generator' import {caseSensitive_Numbs_SpecialCharacters_PW} from 'super-strong-password-generator'
import crypto from 'crypto'; import crypto from 'crypto';
import Fs from 'fs';
import { GBServer } from '../../../src/app.js';
/** /**
* Services for server administration. * Services for server administration.
@ -72,13 +74,9 @@ export class GBAdminService implements IGBAdminService {
} }
public static getNodeVersion () { public static getNodeVersion () {
return '19.1.0';
const packageJson = urlJoin(process.cwd(), 'package.json'); const packageJson = urlJoin(process.cwd(), 'package.json');
// tslint:disable-next-line: non-literal-require const pkg = JSON.parse(Fs.readFileSync(packageJson, 'utf8'));
// TODO return pkg.engines.node.replace('=', '');
// const pjson = require(packageJson);
// return pjson.engines.node.replace('=', '');
} }
public static async getADALTokenFromUsername (username: string, password: string) { public static async getADALTokenFromUsername (username: string, password: string) {
@ -214,10 +212,8 @@ export class GBAdminService implements IGBAdminService {
} }
public async acquireElevatedToken (instanceId: number): Promise<string> { public async acquireElevatedToken (instanceId: number): Promise<string> {
// TODO: Use boot bot as base for authentication. const minBoot = GBServer.globals.minBoot as any;
instanceId = minBoot.instance.instanceId;
const botId = GBConfigService.get('BOT_ID');
instanceId = (await this.core.loadInstanceByBotId(botId)).instanceId;
return new Promise<string>(async (resolve, reject) => { return new Promise<string>(async (resolve, reject) => {
const instance = await this.core.loadInstanceById(instanceId); const instance = await this.core.loadInstanceById(instanceId);

View file

@ -273,7 +273,7 @@ export class DebuggerService {
public async getRunning ({ botId, botApiKey, scriptName }) { public async getRunning ({ botId, botApiKey, scriptName }) {
let error; let error;
botId = botId[0]; // TODO: Handle call in POST. botId = botId[0];
if (!GBServer.globals.debuggers[botId]) { if (!GBServer.globals.debuggers[botId]) {
GBServer.globals.debuggers[botId] = {}; GBServer.globals.debuggers[botId] = {};
} }

View file

@ -125,13 +125,13 @@ export class DialogKeywords {
} }
/** /**
*
* *
* Data = [10,20,30] * Data = [10,20,30]
* Legends = "Steve;Yui;Carlos" * Legends = "Steve;Yui;Carlos"
* img = CHART "pie",data,legends * img = CHART "pie",data,legends
* *
* https://c3js.org/examples.html * https://c3js.org/examples.html
* https://c3js.org/samples/timeseries.html (used here)
* *
* @param data * @param data
* @param legends * @param legends
@ -179,8 +179,6 @@ export class DialogKeywords {
} }
}; };
// TODO: https://c3js.org/samples/timeseries.html
if (type === 'timeseries') { if (type === 'timeseries') {
definition['axis'][table[0]] = { definition['axis'][table[0]] = {
type: 'timeseries', type: 'timeseries',
@ -589,7 +587,7 @@ export class DialogKeywords {
*/ */
public async setMaxLines({ count }) { public async setMaxLines({ count }) {
if (this.user) { if (this.user) {
// TODO: PARAM user.basicOptions.maxLines = count; // #307 user.basicOptions.maxLines = count;
} else { } else {
this.maxLines = count; this.maxLines = count;
} }
@ -602,7 +600,7 @@ export class DialogKeywords {
* *
*/ */
public async setMaxColumns({ count }) { public async setMaxColumns({ count }) {
// TODO: user.basicOptions.maxColumns = count; // #307 user.basicOptions.maxColumns = count;
} }
/** /**
@ -612,7 +610,7 @@ export class DialogKeywords {
* *
*/ */
public async setWholeWord({ on }) { public async setWholeWord({ on }) {
// TODO: user.basicOptions.wholeWord = (on.trim() === "on"); // #307 user.basicOptions.wholeWord = (on.trim() === "on");
} }
/** /**
@ -622,7 +620,7 @@ export class DialogKeywords {
* *
*/ */
public async setTheme({ theme }) { public async setTheme({ theme }) {
// TODO: user.basicOptions.theme = theme.trim(); // #307 user.basicOptions.theme = theme.trim();
} }
/** /**
@ -632,14 +630,14 @@ export class DialogKeywords {
* *
*/ */
public async setTranslatorOn({ on }) { public async setTranslatorOn({ on }) {
// TODO: user.basicOptions.translatorOn = (on.trim() === "on"); // #307 user.basicOptions.translatorOn = (on.trim() === "on");
} }
/** /**
* Returns the name of the user acquired by WhatsApp API. * Returns the name of the user acquired by WhatsApp API.
*/ */
public async userName() { public async userName() {
// TODO: WhatsappDirectLine.usernames[await this.userMobile()] : 'N/A'; // #307 WhatsappDirectLine.usernames[await this.userMobile()] : 'N/A';
return this.sys().getRandomId(); return this.sys().getRandomId();
} }
@ -647,7 +645,7 @@ export class DialogKeywords {
* Returns current mobile number from user in conversation. * Returns current mobile number from user in conversation.
*/ */
public async userMobile() { public async userMobile() {
// TODO: return GBMinService.userMobile(); // #307 return GBMinService.userMobile();
return this.sys().getRandomId(); return this.sys().getRandomId();
} }
@ -658,11 +656,13 @@ export class DialogKeywords {
* *
*/ */
public async showMenu({}) { public async showMenu({}) {
// TODO: return await beginDialog('/menu'); // https://github.com/GeneralBots/BotServer/issues/237
// return await beginDialog('/menu');
} }
private static async downloadAttachmentAndWrite(attachment) { private static async downloadAttachmentAndWrite(attachment) {
const url = attachment.contentUrl; const url = attachment.contentUrl;
const localFolder = Path.join('work'); // TODO: ,'${botId}','uploads'); // https://github.com/GeneralBots/BotServer/issues/195 - '${botId}','uploads');
const localFolder = Path.join('work');
const localFileName = Path.join(localFolder, attachment.name); const localFileName = Path.join(localFolder, attachment.name);
try { try {
@ -706,7 +706,8 @@ export class DialogKeywords {
* *
*/ */
public async transferTo({ to }) { public async transferTo({ to }) {
// TODO: return await beginDialog('/t',{ to: to }); // https://github.com/GeneralBots/BotServer/issues/150
// return await beginDialog('/t',{ to: to });
} }
/** /**
@ -739,12 +740,12 @@ export class DialogKeywords {
let result; let result;
const locale = user.locale ? user.locale : 'en-US'; const locale = user.locale ? user.locale : 'en-US';
// TODO: https://github.com/GeneralBots/BotServer/issues/266 // https://github.com/GeneralBots/BotServer/issues/266
if (args && args.length > 1) { if (args && args.length > 1) {
// TODO: https://github.com/pedroslopez/whatsapp-web.js/issues/1811 // https://github.com/pedroslopez/whatsapp-web.js/issues/1811
// //
// const list = new List( // const list = new List(
// 'Escolha um dos itens', // 'Escolha um dos itens',
@ -889,12 +890,13 @@ export class DialogKeywords {
result = value; result = value;
} else if (kind === 'money') { } else if (kind === 'money') {
const extractEntity = text => { const extractEntity = text => {
// if (user.locale === 'en') { // TODO: Change to user. // https://github.com/GeneralBots/BotServer/issues/307
// return text.match(/(?:\d{1,3},)*\d{1,3}(?:\.\d+)?/gi); if (user.locale === 'en') {
// } return text.match(/(?:\d{1,3},)*\d{1,3}(?:\.\d+)?/gi);
// else { }
// return text.match(/(?:\d{1,3}.)*\d{1,3}(?:\,\d+)?/gi); else {
// } return text.match(/(?:\d{1,3}.)*\d{1,3}(?:\,\d+)?/gi);
}
return []; return [];
}; };
@ -909,7 +911,8 @@ export class DialogKeywords {
} else if (kind === 'mobile') { } else if (kind === 'mobile') {
let phoneNumber; let phoneNumber;
try { try {
phoneNumber = phone(text, { country: 'BRA' })[0]; // TODO: Use accordingly to the person. // https://github.com/GeneralBots/BotServer/issues/307
phoneNumber = phone(text, { country: 'BRA' })[0];
phoneNumber = phoneUtil.parse(phoneNumber); phoneNumber = phoneUtil.parse(phoneNumber);
} catch (error) { } catch (error) {
await this.talk(Messages[locale].validation_enter_valid_mobile); await this.talk(Messages[locale].validation_enter_valid_mobile);
@ -927,7 +930,7 @@ export class DialogKeywords {
text = text.replace(/\-/gi, ''); text = text.replace(/\-/gi, '');
if (user.locale === 'en') { if (user.locale === 'en') {
// TODO: Change to user. // https://github.com/GeneralBots/BotServer/issues/307
return text.match(/\d{8}/gi); return text.match(/\d{8}/gi);
} else { } else {
return text.match(/(?:\d{1,3}.)*\d{1,3}(?:\,\d+)?/gi); return text.match(/(?:\d{1,3}.)*\d{1,3}(?:\,\d+)?/gi);
@ -1000,7 +1003,8 @@ export class DialogKeywords {
public async gotoDialog({ fromOrDialogName, dialogName }) { public async gotoDialog({ fromOrDialogName, dialogName }) {
if (dialogName) { if (dialogName) {
if (dialogName.charAt(0) === '/') { if (dialogName.charAt(0) === '/') {
// TODO: await step.beginDialog(fromOrDialogName); // https://github.com/GeneralBots/BotServer/issues/308
// await step.beginDialog(fromOrDialogName);
} else { } else {
let sec = new SecService(); let sec = new SecService();
let user = await sec.getUserFromSystemId(fromOrDialogName); let user = await sec.getUserFromSystemId(fromOrDialogName);
@ -1018,7 +1022,8 @@ export class DialogKeywords {
await sec.updateUserHearOnDialog(user.userId, dialogName); await sec.updateUserHearOnDialog(user.userId, dialogName);
} }
} else { } else {
// TODO: await step.beginDialog(fromOrDialogName); // https://github.com/GeneralBots/BotServer/issues/308
// await step.beginDialog(fromOrDialogName);
} }
} }
@ -1051,7 +1056,7 @@ export class DialogKeywords {
private static getChannel(): string { private static getChannel(): string {
return 'whatsapp'; return 'whatsapp';
// TODO: // https://github.com/GeneralBots/BotServer/issues/309
} }
/** /**

View file

@ -866,7 +866,8 @@ export class GBVMService extends GBService {
keywords[i++] = [ keywords[i++] = [
/^\s*(click)(\s*)(.*)/gim, /^\s*(click)(\s*)(.*)/gim,
($0, $1, $2, $3) => { ($0, $1, $2, $3) => {
// TODO: page is not string. // page is not string.
// https://github.com/GeneralBots/BotServer/issues/310
const params = this.getParams('page,' + $3, ['handle', 'frameOrSelector', 'selector']); const params = this.getParams('page,' + $3, ['handle', 'frameOrSelector', 'selector']);
return `await wa.click (${params})\n`; return `await wa.click (${params})\n`;
} }

View file

@ -87,7 +87,7 @@ export class SystemKeywords {
} }
public async callVM ({ text }) { public async callVM ({ text }) {
// TODO:
const min = null; const min = null;
const step = null; const step = null;
const deployer = null; const deployer = null;
@ -579,8 +579,7 @@ export class SystemKeywords {
headers: addressOrHeaders, headers: addressOrHeaders,
username: httpUsername, username: httpUsername,
ps: httpPs, ps: httpPs,
qs, qs
streaming
}); });
} else { } else {
GBLog.info(`BASIC: GET '${addressOrHeaders}' in '${file}'.`); GBLog.info(`BASIC: GET '${addressOrHeaders}' in '${file}'.`);
@ -651,7 +650,6 @@ export class SystemKeywords {
* loop * loop
* @see NPM package data-forge * @see NPM package data-forge
* *
* // TODO: https://www.npmjs.com/package/parse-markdown-table
*/ */
public async find ({ args }): Promise<any> { public async find ({ args }): Promise<any> {
const file = args[0]; const file = args[0];
@ -1279,7 +1277,7 @@ export class SystemKeywords {
* @example user = get "http://server/users/1" * @example user = get "http://server/users/1"
* *
*/ */
public async getByHttp ({ url, headers, username, ps, qs, streaming }) { public async getByHttp ({ url, headers, username, ps, qs}) {
let options = { }; let options = { };
if (headers) { if (headers) {
options['headers'] = headers; options['headers'] = headers;
@ -1293,10 +1291,7 @@ export class SystemKeywords {
if (qs) { if (qs) {
options['qs'] = qs; options['qs'] = qs;
} }
if (streaming) { // TODO: Do it with fetch.
options['responseType'] = 'stream';
options['encoding'] = null;
}fetch
const result = await fetch(url, options); const result = await fetch(url, options);
try { try {

View file

@ -308,8 +308,10 @@ export class WebAutomationKeywords {
*/ */
public async download ({ handle, selector, folder }) { public async download ({ handle, selector, folder }) {
const page = this.getPageByHandle(handle); const page = this.getPageByHandle(handle);
const container = page; // TODO: element['_frame'] ? element['_frame'] : element['_page'];
const element = await this.getBySelector({ handle, selector }); const element = await this.getBySelector({ handle, selector });
// https://github.com/GeneralBots/BotServer/issues/311
const container = element['_frame'] ? element['_frame'] : element['_page'];
await page.setRequestInterception(true); await page.setRequestInterception(true);
await container.click(element.originalSelector); await container.click(element.originalSelector);

View file

@ -2,7 +2,6 @@
"enabledAdmin": "true", "enabledAdmin": "true",
"searchScore": ".45", "searchScore": ".45",
"nlpScore": ".80", "nlpScore": ".80",
"nlpVsSearch": ".4",
"state":"active", "state":"active",
"autoPackageSync": "gbdialog, gbot, gbtheme" "autoPackageSync": "gbdialog, gbot, gbtheme"
} }

View file

@ -249,9 +249,6 @@ export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInst
@Column(DataType.STRING(255)) @Column(DataType.STRING(255))
declare adminPass: string; declare adminPass: string;
@Column(DataType.FLOAT)
declare nlpVsSearch: number; // TODO: Remove field.
@Column(DataType.FLOAT) @Column(DataType.FLOAT)
declare searchScore: number; declare searchScore: number;

View file

@ -571,11 +571,11 @@ export class GBConversationalService {
xhtml: false xhtml: false
}); });
// MSFT Translator breaks markdown, so we need to fix it: // MSFT Translator breaks markdown, so we need to manually fix it:
text = text.replace('! [', '![').replace('] (', ']('); text = text.replace('! [', '![').replace('] (', '](');
text = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', ''); // TODO: Improve it. text = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', '');
text = text.replace(`](kb`, '](' + process.env.BOT_URL + '/kb'); // TODO: Improve it. text = text.replace(`](kb`, '](' + process.env.BOT_URL + '/kb');
if (mobile) { if (mobile) {
await this.sendMarkdownToMobile(min, step, mobile, text); await this.sendMarkdownToMobile(min, step, mobile, text);
@ -597,8 +597,8 @@ export class GBConversationalService {
data: { data: {
content: html, content: html,
answer: answer, answer: answer,
prevId: 0, // TODO: answer.prevId, prevId: 0, // https://github.com/GeneralBots/BotServer/issues/312
nextId: 0 // TODO: answer.nextId nextId: 0
} }
}); });
} }
@ -775,11 +775,7 @@ export class GBConversationalService {
} }
} }
// TODO: Update botlib. public async routeNLP (step: GBDialogStep, min: GBMinInstance, text: string) {
public async routeNLP (step: GBDialogStep, min: GBMinInstance, text: string): Promise<boolean> {
return false;
}
public async routeNLP2 (step: GBDialogStep, min: GBMinInstance, text: string) {
if (min.instance.nlpAppId === null || min.instance.nlpAppId === undefined) { if (min.instance.nlpAppId === null || min.instance.nlpAppId === undefined) {
return false; return false;
} }

View file

@ -463,7 +463,7 @@ export class GBDeployer implements IGBDeployer {
GBLog.info(`downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`); GBLog.info(`downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`);
if (!baseUrl) { if (!baseUrl) {
client = await GBDeployer.internalGetDriveClient(min); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
remotePath = remotePath.replace(/\\/gi, '/'); remotePath = remotePath.replace(/\\/gi, '/');
const parts = remotePath.split('/'); const parts = remotePath.split('/');
@ -490,7 +490,7 @@ export class GBDeployer implements IGBDeployer {
GBLog.info(`Download URL: ${url}`); GBLog.info(`Download URL: ${url}`);
const res = await client.client.api(url).get(); const res = await client.api(url).get();
const documents = res.value; const documents = res.value;
if (documents === undefined || documents.length === 0) { if (documents === undefined || documents.length === 0) {
GBLog.info(`${remotePath} is an empty folder.`); GBLog.info(`${remotePath} is an empty folder.`);
@ -880,6 +880,10 @@ export class GBDeployer implements IGBDeployer {
const m = await import(gbappPath); const m = await import(gbappPath);
if (m.Package) { if (m.Package) {
const p = new m.Package(); const p = new m.Package();
// Adds a name property to the list of loaded .gbapp packages.
p['name'] = gbappPath;
await p.loadPackage(core, core.sequelize); await p.loadPackage(core, core.sequelize);
if (appPackages !== undefined) { if (appPackages !== undefined) {
appPackages.push(p); appPackages.push(p);

View file

@ -257,7 +257,8 @@ export class GBMinService {
GBServer.globals.appPackages GBServer.globals.appPackages
); );
// TODO: min['groupCache'] = await KBService.getGroupReplies(instance.instanceId); // https://github.com/GeneralBots/BotServer/issues/286
// min['groupCache'] = await KBService.getGroupReplies(instance.instanceId);
GBServer.globals.minInstances.push(min); GBServer.globals.minInstances.push(min);
@ -298,7 +299,8 @@ export class GBMinService {
// Loads Named Entity data for this bot. // Loads Named Entity data for this bot.
// TODO: await KBService.RefreshNER(min); // https://github.com/GeneralBots/BotServer/issues/217
// await KBService.RefreshNER(min);
// Calls the loadBot context.activity for all packages. // Calls the loadBot context.activity for all packages.
@ -485,7 +487,7 @@ export class GBMinService {
await this.adminService.setValue(instance.instanceId, 'accessToken', token['accessToken']); await this.adminService.setValue(instance.instanceId, 'accessToken', token['accessToken']);
await this.adminService.setValue(instance.instanceId, 'refreshToken', token['refreshToken']); await this.adminService.setValue(instance.instanceId, 'refreshToken', token['refreshToken']);
await this.adminService.setValue(instance.instanceId, 'expiresOn', token['expiresOn'].toString()); await this.adminService.setValue(instance.instanceId, 'expiresOn', token['expiresOn'].toString());
await this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', undefined); await this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', null);
// Inform the home for default .gbui after finishing token retrival. // Inform the home for default .gbui after finishing token retrival.
@ -651,7 +653,7 @@ export class GBMinService {
min.sandBoxMap = {}; min.sandBoxMap = {};
min['scheduleMap'] = {}; min['scheduleMap'] = {};
min['conversationWelcomed'] = {}; min['conversationWelcomed'] = {};
min['nerEngine'] = new nlp.NlpManager(); // TODO: migrate to MerManager. min['nerEngine'] = new nlp.NlpManager(); // https://github.com/GeneralBots/BotServer/issues/217
min.packages = sysPackages; min.packages = sysPackages;
min.appPackages = appPackages; min.appPackages = appPackages;
@ -666,7 +668,8 @@ export class GBMinService {
access_token: min.instance.facebookWorkplaceAccessToken access_token: min.instance.facebookWorkplaceAccessToken
}); });
} }
// TODO: min.appPackages = core.getPackagesByInstanceId(min.instance.instanceId); // https://github.com/GeneralBots/BotServer/issues/123
// min.appPackages = core.getPackagesByInstanceId(min.instance.instanceId);
// Creates a hub of services available in .gbapps. // Creates a hub of services available in .gbapps.
@ -785,7 +788,7 @@ export class GBMinService {
}); });
} }
// TODO: Unify in util. // https://github.com/GeneralBots/BotServer/issues/313
public static userMobile (step) { public static userMobile (step) {
let mobile = WhatsappDirectLine.mobiles[step.context.activity.conversation.id]; let mobile = WhatsappDirectLine.mobiles[step.context.activity.conversation.id];
@ -907,8 +910,7 @@ export class GBMinService {
headers, headers,
username: null, username: null,
ps: null, ps: null,
qs: null, qs: null
streaming: true
}); });
const folder = `work/${min.instance.botId}.gbai/cache`; const folder = `work/${min.instance.botId}.gbai/cache`;
const filename = `${GBAdminService.generateUuid()}.png`; const filename = `${GBAdminService.generateUuid()}.png`;
@ -1080,7 +1082,6 @@ export class GBMinService {
let data = { query: context.activity.text }; let data = { query: context.activity.text };
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => { await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
await e.onExchangeData(min, 'handleRawInput', data); await e.onExchangeData(min, 'handleRawInput', data);
// TODO: Handle priority over .gbapp, today most common case is just one item per server.
}); });
context.activity.text = data.query; context.activity.text = data.query;

View file

@ -286,7 +286,7 @@ export class FeedbackDialog extends IGBDialog {
min.instance, min.instance,
'Feedback Improve Message', 'Feedback Improve Message',
Messages[fixedLocale].we_will_improve Messages[fixedLocale].we_will_improve
); // TODO: Improve to be multi-language. );
await min.conversationalService.sendText(min, step, message); await min.conversationalService.sendText(min, step, message);
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -121,7 +121,6 @@ export class GoogleChatDirectLine extends GBService {
GBLog.info(`GBGoogleChat: Checking server...`); GBLog.info(`GBGoogleChat: Checking server...`);
} }
// TODO: Check service.Users.Messages.List("me").
public async receiver (message) { public async receiver (message) {
const event = JSON.parse(Buffer.from(message.data, 'binary').toString()); const event = JSON.parse(Buffer.from(message.data, 'binary').toString());

View file

@ -262,7 +262,7 @@ export class AskDialog extends IGBDialog {
// Tries to answer by NLP. // Tries to answer by NLP.
let nextDialog = await min.conversationalService['routeNLP2'](step, min, text); let nextDialog = await min.conversationalService.routeNLP(step, min, text);
if (nextDialog) { if (nextDialog) {
return nextDialog; return nextDialog;
} }

View file

@ -307,8 +307,7 @@ export class KBService implements IGBKBService {
top: 1 top: 1
}); });
const values = results.results; // TODO: See. const values = results.results;
let returnedScore = 0; let returnedScore = 0;
// Searches via Search (Azure Search). // Searches via Search (Azure Search).
@ -542,7 +541,8 @@ export class KBService implements IGBKBService {
}; };
questions.push(question1); questions.push(question1);
// TODO: Tutorial. if (lastAnswer !== undefined && lastQuestionId !== 0) { // https://github.com/GeneralBots/BotServer/issues/312
// if (lastAnswer !== undefined && lastQuestionId !== 0) {
// await lastAnswer.update({ nextId: lastQuestionId }); // await lastAnswer.update({ nextId: lastQuestionId });
// } // }
// lastAnswer = answer1; // lastAnswer = answer1;
@ -648,7 +648,7 @@ export class KBService implements IGBKBService {
format: '.md', format: '.md',
media: file.name, media: file.name,
packageId: packageId, packageId: packageId,
prevId: 0 // TODO: Calculate total rows and increment. prevId: 0 // https://github.com/GeneralBots/BotServer/issues/312
}); });
} }
} }

View file

@ -104,7 +104,7 @@ export class ProfileDialog extends IGBDialog {
let phoneNumber; let phoneNumber;
try { try {
let p = phone.PhoneNumberUtil.getInstance(); let p = phone.PhoneNumberUtil.getInstance();
phoneNumber = p(step.result, 'BRA')[0]; // TODO: Use accordingly to the person. phoneNumber = p(step.result, 'BRA')[0]; // https://github.com/GeneralBots/BotServer/issues/307
phoneNumber = phone.phoneUtil.parse(phoneNumber); phoneNumber = phone.phoneUtil.parse(phoneNumber);
} catch (error) { } catch (error) {
await step.context.sendActivity(Messages[locale].validation_enter_valid_mobile); await step.context.sendActivity(Messages[locale].validation_enter_valid_mobile);

View file

@ -130,10 +130,6 @@ export class WhatsappDirectLine extends GBService {
case 'GeneralBots': case 'GeneralBots':
const minBoot = GBServer.globals.minBoot as any; const minBoot = GBServer.globals.minBoot as any;
// TODO: REMOVE THIS.
if (minBoot.botId !== this.botId) {
this.customClient = minBoot.whatsAppDirectLine.customClient;
} else {
// Initialize the browser using a local profile for each bot. // Initialize the browser using a local profile for each bot.
const gbaiName = `${this.min.botId}.gbai`; const gbaiName = `${this.min.botId}.gbai`;
@ -251,7 +247,7 @@ export class WhatsappDirectLine extends GBService {
await createClient.bind(this)(this.browserWSEndpoint); await createClient.bind(this)(this.browserWSEndpoint);
setUrl = false; setUrl = false;
}
break; break;
case 'chatapi': case 'chatapi':
@ -542,7 +538,9 @@ export class WhatsappDirectLine extends GBService {
await this.min.conversationalService.sendMarkdownToMobile(this.min, null, user.userSystemId, message); await this.min.conversationalService.sendMarkdownToMobile(this.min, null, user.userSystemId, message);
} }
} else if (text === '/qt') { } else if (text === '/qt') {
// TODO: Transfers only in pt-br for now.
// https://github.com/GeneralBots/BotServer/issues/307
await this.sendToDeviceEx( await this.sendToDeviceEx(
manualUser.userSystemId, manualUser.userSystemId,
Messages[this.locale].notify_end_transfer(this.min.instance.botId), Messages[this.locale].notify_end_transfer(this.min.instance.botId),