Merge branch 'master' of https://github.com/AlanPerdomo/BotServer
This commit is contained in:
commit
943644313d
24 changed files with 131 additions and 43448 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -11,6 +11,8 @@
|
|||
/packages/default.gbui/build
|
||||
/packages/default.gbui/.env
|
||||
/packages/default.gbui/node_modules
|
||||
/packages/default.gbui/package-lock.json
|
||||
/packages/default.gbui/yarn-lock.json
|
||||
/work
|
||||
*.vbs.compiled
|
||||
*.vbs.js
|
||||
|
@ -23,4 +25,5 @@ GB.log
|
|||
gb.log
|
||||
GB.log.json
|
||||
yarn-error.log
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
yarn-lock.json
|
|
@ -12,7 +12,7 @@ before_script:
|
|||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- main
|
||||
- /^greenkeeper/.*$/
|
||||
except:
|
||||
- /^v\d+\.\d+\.\d+$/
|
||||
|
|
22
CHANGELOG.md
22
CHANGELOG.md
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "botserver",
|
||||
"version": "2.0.180",
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"description": "General Bot Community Edition open-core server.",
|
||||
"main": "./boot.mjs",
|
||||
|
@ -14,7 +14,7 @@
|
|||
"Dário Vieira <dario.junior3@gmail.com>"
|
||||
],
|
||||
"engines": {
|
||||
"node": "=19.2.0"
|
||||
"node": "=19.3.0"
|
||||
},
|
||||
"license": "AGPL-3.0",
|
||||
"preferGlobal": true,
|
||||
|
@ -85,7 +85,7 @@
|
|||
"botbuilder-ai": "4.18.0",
|
||||
"botbuilder-dialogs": "4.18.0",
|
||||
"botframework-connector": "4.18.0",
|
||||
"botlib": "3.0.0",
|
||||
"botlib": "3.0.2",
|
||||
"c3-chart-maker": "0.2.8",
|
||||
"chatgpt": "2.4.2",
|
||||
"chrome-remote-interface": "0.31.3",
|
||||
|
|
|
@ -50,11 +50,11 @@ import { CollectionUtil } from 'pragmatismo-io-framework';
|
|||
* Dialogs for administration tasks.
|
||||
*/
|
||||
export class AdminDialog extends IGBDialog {
|
||||
public static isIntentYes (locale, utterance) {
|
||||
public static isIntentYes(locale, utterance) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ export class AdminDialog extends IGBDialog {
|
|||
* @param bot The bot adapter.
|
||||
* @param min The minimal bot instance data.
|
||||
*/
|
||||
public static setup (min: GBMinInstance) {
|
||||
public static setup(min: GBMinInstance) {
|
||||
// Setup services.
|
||||
|
||||
const importer = new GBImporter(min.core);
|
||||
|
@ -217,12 +217,19 @@ export class AdminDialog extends IGBDialog {
|
|||
// If the user says yes, starts publishing.
|
||||
|
||||
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;
|
||||
|
||||
for (let index = 0; index < min.appPackages.length; index++) {
|
||||
const element = min.appPackages[index];
|
||||
await element.onExchangeData(min, 'install', null);
|
||||
// TODO: Filter just to the .gbapp being installed.
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await min.conversationalService.sendText(min, step, Messages[locale].publish_canceled);
|
||||
|
@ -308,9 +315,7 @@ export class AdminDialog extends IGBDialog {
|
|||
try {
|
||||
let cmd1;
|
||||
if (packageName.indexOf('.') !== -1) {
|
||||
cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${
|
||||
process.env.STORAGE_LIBRARY
|
||||
}/${botId}.gbai/${packageName}`;
|
||||
cmd1 = `deployPackage ${process.env.STORAGE_SITE} /${process.env.STORAGE_LIBRARY}/${botId}.gbai/${packageName}`;
|
||||
} else {
|
||||
cmd1 = `deployPackage ${packageName}`;
|
||||
}
|
||||
|
@ -348,7 +353,7 @@ export class AdminDialog extends IGBDialog {
|
|||
* the /broadcast command with specific phone numbers.
|
||||
* @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) {
|
||||
let list = process.env.SECURITY_CAN_PUBLISH.split(';');
|
||||
|
||||
|
@ -361,13 +366,15 @@ export class AdminDialog extends IGBDialog {
|
|||
|
||||
if (!result && min.instance.params) {
|
||||
const params = JSON.parse(min.instance.params);
|
||||
return list.includes(params['Can Publish']);
|
||||
if (params){
|
||||
return list.includes(params['Can Publish']);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static setupSecurityDialogs (min: GBMinInstance) {
|
||||
private static setupSecurityDialogs(min: GBMinInstance) {
|
||||
min.dialogs.add(
|
||||
new WaterfallDialog('/setupSecurity', [
|
||||
async step => {
|
||||
|
@ -410,11 +417,7 @@ export class AdminDialog extends IGBDialog {
|
|||
min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
|
||||
|
||||
const redirectUri = urlJoin(min.instance.botEndpoint, min.instance.botId, '/token');
|
||||
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`;
|
||||
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`;
|
||||
|
||||
await min.conversationalService.sendText(min, step, Messages[locale].consent(url));
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ import msRestAzure from 'ms-rest-azure';
|
|||
import Path from 'path';
|
||||
import {caseSensitive_Numbs_SpecialCharacters_PW} from 'super-strong-password-generator'
|
||||
import crypto from 'crypto';
|
||||
import Fs from 'fs';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
|
||||
/**
|
||||
* Services for server administration.
|
||||
|
@ -72,13 +74,9 @@ export class GBAdminService implements IGBAdminService {
|
|||
}
|
||||
|
||||
public static getNodeVersion () {
|
||||
return '19.1.0';
|
||||
const packageJson = urlJoin(process.cwd(), 'package.json');
|
||||
// tslint:disable-next-line: non-literal-require
|
||||
// TODO
|
||||
// const pjson = require(packageJson);
|
||||
|
||||
// return pjson.engines.node.replace('=', '');
|
||||
const pkg = JSON.parse(Fs.readFileSync(packageJson, 'utf8'));
|
||||
return pkg.engines.node.replace('=', '');
|
||||
}
|
||||
|
||||
public static async getADALTokenFromUsername (username: string, password: string) {
|
||||
|
@ -214,10 +212,8 @@ export class GBAdminService implements IGBAdminService {
|
|||
}
|
||||
|
||||
public async acquireElevatedToken (instanceId: number): Promise<string> {
|
||||
// TODO: Use boot bot as base for authentication.
|
||||
|
||||
const botId = GBConfigService.get('BOT_ID');
|
||||
instanceId = (await this.core.loadInstanceByBotId(botId)).instanceId;
|
||||
const minBoot = GBServer.globals.minBoot as any;
|
||||
instanceId = minBoot.instance.instanceId;
|
||||
|
||||
return new Promise<string>(async (resolve, reject) => {
|
||||
const instance = await this.core.loadInstanceById(instanceId);
|
||||
|
|
|
@ -273,7 +273,7 @@ export class DebuggerService {
|
|||
|
||||
public async getRunning ({ botId, botApiKey, scriptName }) {
|
||||
let error;
|
||||
botId = botId[0]; // TODO: Handle call in POST.
|
||||
botId = botId[0];
|
||||
if (!GBServer.globals.debuggers[botId]) {
|
||||
GBServer.globals.debuggers[botId] = {};
|
||||
}
|
||||
|
|
|
@ -125,13 +125,13 @@ export class DialogKeywords {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Data = [10,20,30]
|
||||
* Legends = "Steve;Yui;Carlos"
|
||||
* img = CHART "pie",data,legends
|
||||
*
|
||||
* https://c3js.org/examples.html
|
||||
* https://c3js.org/samples/timeseries.html (used here)
|
||||
*
|
||||
* @param data
|
||||
* @param legends
|
||||
|
@ -179,8 +179,6 @@ export class DialogKeywords {
|
|||
}
|
||||
};
|
||||
|
||||
// TODO: https://c3js.org/samples/timeseries.html
|
||||
|
||||
if (type === 'timeseries') {
|
||||
definition['axis'][table[0]] = {
|
||||
type: 'timeseries',
|
||||
|
@ -589,7 +587,7 @@ export class DialogKeywords {
|
|||
*/
|
||||
public async setMaxLines({ count }) {
|
||||
if (this.user) {
|
||||
// TODO: PARAM user.basicOptions.maxLines = count;
|
||||
// #307 user.basicOptions.maxLines = count;
|
||||
} else {
|
||||
this.maxLines = count;
|
||||
}
|
||||
|
@ -602,7 +600,7 @@ export class DialogKeywords {
|
|||
*
|
||||
*/
|
||||
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 }) {
|
||||
// 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 }) {
|
||||
// TODO: user.basicOptions.theme = theme.trim();
|
||||
// #307 user.basicOptions.theme = theme.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -632,14 +630,14 @@ export class DialogKeywords {
|
|||
*
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public async userName() {
|
||||
// TODO: WhatsappDirectLine.usernames[await this.userMobile()] : 'N/A';
|
||||
// #307 WhatsappDirectLine.usernames[await this.userMobile()] : 'N/A';
|
||||
return this.sys().getRandomId();
|
||||
}
|
||||
|
||||
|
@ -647,7 +645,7 @@ export class DialogKeywords {
|
|||
* Returns current mobile number from user in conversation.
|
||||
*/
|
||||
public async userMobile() {
|
||||
// TODO: return GBMinService.userMobile();
|
||||
// #307 return GBMinService.userMobile();
|
||||
return this.sys().getRandomId();
|
||||
}
|
||||
|
||||
|
@ -658,11 +656,13 @@ export class DialogKeywords {
|
|||
*
|
||||
*/
|
||||
public async showMenu({}) {
|
||||
// TODO: return await beginDialog('/menu');
|
||||
// https://github.com/GeneralBots/BotServer/issues/237
|
||||
// return await beginDialog('/menu');
|
||||
}
|
||||
private static async downloadAttachmentAndWrite(attachment) {
|
||||
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);
|
||||
|
||||
try {
|
||||
|
@ -706,7 +706,8 @@ export class DialogKeywords {
|
|||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
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) {
|
||||
|
||||
|
||||
// TODO: https://github.com/pedroslopez/whatsapp-web.js/issues/1811
|
||||
// https://github.com/pedroslopez/whatsapp-web.js/issues/1811
|
||||
//
|
||||
// const list = new List(
|
||||
// 'Escolha um dos itens',
|
||||
|
@ -889,12 +890,13 @@ export class DialogKeywords {
|
|||
result = value;
|
||||
} else if (kind === 'money') {
|
||||
const extractEntity = text => {
|
||||
// if (user.locale === 'en') { // TODO: Change to user.
|
||||
// return text.match(/(?:\d{1,3},)*\d{1,3}(?:\.\d+)?/gi);
|
||||
// }
|
||||
// else {
|
||||
// return text.match(/(?:\d{1,3}.)*\d{1,3}(?:\,\d+)?/gi);
|
||||
// }
|
||||
// https://github.com/GeneralBots/BotServer/issues/307
|
||||
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);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
|
@ -909,7 +911,8 @@ export class DialogKeywords {
|
|||
} else if (kind === 'mobile') {
|
||||
let phoneNumber;
|
||||
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);
|
||||
} catch (error) {
|
||||
await this.talk(Messages[locale].validation_enter_valid_mobile);
|
||||
|
@ -927,7 +930,7 @@ export class DialogKeywords {
|
|||
text = text.replace(/\-/gi, '');
|
||||
|
||||
if (user.locale === 'en') {
|
||||
// TODO: Change to user.
|
||||
// https://github.com/GeneralBots/BotServer/issues/307
|
||||
return text.match(/\d{8}/gi);
|
||||
} else {
|
||||
return text.match(/(?:\d{1,3}.)*\d{1,3}(?:\,\d+)?/gi);
|
||||
|
@ -1000,7 +1003,8 @@ export class DialogKeywords {
|
|||
public async gotoDialog({ fromOrDialogName, dialogName }) {
|
||||
if (dialogName) {
|
||||
if (dialogName.charAt(0) === '/') {
|
||||
// TODO: await step.beginDialog(fromOrDialogName);
|
||||
// https://github.com/GeneralBots/BotServer/issues/308
|
||||
// await step.beginDialog(fromOrDialogName);
|
||||
} else {
|
||||
let sec = new SecService();
|
||||
let user = await sec.getUserFromSystemId(fromOrDialogName);
|
||||
|
@ -1018,7 +1022,8 @@ export class DialogKeywords {
|
|||
await sec.updateUserHearOnDialog(user.userId, dialogName);
|
||||
}
|
||||
} 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 {
|
||||
return 'whatsapp';
|
||||
// TODO:
|
||||
// https://github.com/GeneralBots/BotServer/issues/309
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -866,7 +866,8 @@ export class GBVMService extends GBService {
|
|||
keywords[i++] = [
|
||||
/^\s*(click)(\s*)(.*)/gim,
|
||||
($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']);
|
||||
return `await wa.click (${params})\n`;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export class SystemKeywords {
|
|||
}
|
||||
|
||||
public async callVM ({ text }) {
|
||||
// TODO:
|
||||
|
||||
const min = null;
|
||||
const step = null;
|
||||
const deployer = null;
|
||||
|
@ -579,8 +579,7 @@ export class SystemKeywords {
|
|||
headers: addressOrHeaders,
|
||||
username: httpUsername,
|
||||
ps: httpPs,
|
||||
qs,
|
||||
streaming
|
||||
qs
|
||||
});
|
||||
} else {
|
||||
GBLog.info(`BASIC: GET '${addressOrHeaders}' in '${file}'.`);
|
||||
|
@ -651,7 +650,6 @@ export class SystemKeywords {
|
|||
* loop
|
||||
* @see NPM package data-forge
|
||||
*
|
||||
* // TODO: https://www.npmjs.com/package/parse-markdown-table
|
||||
*/
|
||||
public async find ({ args }): Promise<any> {
|
||||
const file = args[0];
|
||||
|
@ -1279,7 +1277,7 @@ export class SystemKeywords {
|
|||
* @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 = { };
|
||||
if (headers) {
|
||||
options['headers'] = headers;
|
||||
|
@ -1293,10 +1291,7 @@ export class SystemKeywords {
|
|||
if (qs) {
|
||||
options['qs'] = qs;
|
||||
}
|
||||
if (streaming) { // TODO: Do it with fetch.
|
||||
options['responseType'] = 'stream';
|
||||
options['encoding'] = null;
|
||||
}fetch
|
||||
|
||||
const result = await fetch(url, options);
|
||||
|
||||
try {
|
||||
|
|
|
@ -308,8 +308,10 @@ export class WebAutomationKeywords {
|
|||
*/
|
||||
public async download ({ handle, selector, folder }) {
|
||||
const page = this.getPageByHandle(handle);
|
||||
const container = page; // TODO: element['_frame'] ? element['_frame'] : element['_page'];
|
||||
|
||||
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 container.click(element.originalSelector);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
"enabledAdmin": "true",
|
||||
"searchScore": ".45",
|
||||
"nlpScore": ".80",
|
||||
"nlpVsSearch": ".4",
|
||||
"state":"active",
|
||||
"autoPackageSync": "gbdialog, gbot, gbtheme"
|
||||
}
|
||||
|
|
|
@ -249,9 +249,6 @@ export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInst
|
|||
@Column(DataType.STRING(255))
|
||||
declare adminPass: string;
|
||||
|
||||
@Column(DataType.FLOAT)
|
||||
declare nlpVsSearch: number; // TODO: Remove field.
|
||||
|
||||
@Column(DataType.FLOAT)
|
||||
declare searchScore: number;
|
||||
|
||||
|
|
|
@ -571,11 +571,11 @@ export class GBConversationalService {
|
|||
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(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', ''); // TODO: Improve it.
|
||||
text = text.replace(`](kb`, '](' + process.env.BOT_URL + '/kb'); // TODO: Improve it.
|
||||
text = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', '');
|
||||
text = text.replace(`](kb`, '](' + process.env.BOT_URL + '/kb');
|
||||
|
||||
if (mobile) {
|
||||
await this.sendMarkdownToMobile(min, step, mobile, text);
|
||||
|
@ -597,8 +597,8 @@ export class GBConversationalService {
|
|||
data: {
|
||||
content: html,
|
||||
answer: answer,
|
||||
prevId: 0, // TODO: answer.prevId,
|
||||
nextId: 0 // TODO: answer.nextId
|
||||
prevId: 0, // https://github.com/GeneralBots/BotServer/issues/312
|
||||
nextId: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -775,11 +775,7 @@ export class GBConversationalService {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Update botlib.
|
||||
public async routeNLP (step: GBDialogStep, min: GBMinInstance, text: string): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
public async routeNLP2 (step: GBDialogStep, min: GBMinInstance, text: string) {
|
||||
public async routeNLP (step: GBDialogStep, min: GBMinInstance, text: string) {
|
||||
if (min.instance.nlpAppId === null || min.instance.nlpAppId === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
GBLog.info(`downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`);
|
||||
|
||||
if (!baseUrl) {
|
||||
client = await GBDeployer.internalGetDriveClient(min);
|
||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||
|
||||
remotePath = remotePath.replace(/\\/gi, '/');
|
||||
const parts = remotePath.split('/');
|
||||
|
@ -490,7 +490,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
GBLog.info(`Download URL: ${url}`);
|
||||
|
||||
const res = await client.client.api(url).get();
|
||||
const res = await client.api(url).get();
|
||||
const documents = res.value;
|
||||
if (documents === undefined || documents.length === 0) {
|
||||
GBLog.info(`${remotePath} is an empty folder.`);
|
||||
|
@ -880,6 +880,10 @@ export class GBDeployer implements IGBDeployer {
|
|||
const m = await import(gbappPath);
|
||||
if (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);
|
||||
if (appPackages !== undefined) {
|
||||
appPackages.push(p);
|
||||
|
|
|
@ -257,7 +257,8 @@ export class GBMinService {
|
|||
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);
|
||||
|
||||
|
@ -298,7 +299,8 @@ export class GBMinService {
|
|||
|
||||
// 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.
|
||||
|
||||
|
@ -485,7 +487,7 @@ export class GBMinService {
|
|||
await this.adminService.setValue(instance.instanceId, 'accessToken', token['accessToken']);
|
||||
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, 'AntiCSRFAttackState', undefined);
|
||||
await this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', null);
|
||||
|
||||
// Inform the home for default .gbui after finishing token retrival.
|
||||
|
||||
|
@ -651,7 +653,7 @@ export class GBMinService {
|
|||
min.sandBoxMap = {};
|
||||
min['scheduleMap'] = {};
|
||||
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.appPackages = appPackages;
|
||||
|
||||
|
@ -666,7 +668,8 @@ export class GBMinService {
|
|||
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.
|
||||
|
||||
|
@ -785,7 +788,7 @@ export class GBMinService {
|
|||
});
|
||||
}
|
||||
|
||||
// TODO: Unify in util.
|
||||
// https://github.com/GeneralBots/BotServer/issues/313
|
||||
public static userMobile (step) {
|
||||
let mobile = WhatsappDirectLine.mobiles[step.context.activity.conversation.id];
|
||||
|
||||
|
@ -907,8 +910,7 @@ export class GBMinService {
|
|||
headers,
|
||||
username: null,
|
||||
ps: null,
|
||||
qs: null,
|
||||
streaming: true
|
||||
qs: null
|
||||
});
|
||||
const folder = `work/${min.instance.botId}.gbai/cache`;
|
||||
const filename = `${GBAdminService.generateUuid()}.png`;
|
||||
|
@ -1080,7 +1082,6 @@ export class GBMinService {
|
|||
let data = { query: context.activity.text };
|
||||
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
||||
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;
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ export class FeedbackDialog extends IGBDialog {
|
|||
min.instance,
|
||||
'Feedback Improve Message',
|
||||
Messages[fixedLocale].we_will_improve
|
||||
); // TODO: Improve to be multi-language.
|
||||
);
|
||||
|
||||
await min.conversationalService.sendText(min, step, message);
|
||||
}
|
||||
|
|
33158
packages/default.gbui/package-lock.json
generated
33158
packages/default.gbui/package-lock.json
generated
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -121,7 +121,6 @@ export class GoogleChatDirectLine extends GBService {
|
|||
GBLog.info(`GBGoogleChat: Checking server...`);
|
||||
}
|
||||
|
||||
// TODO: Check service.Users.Messages.List("me").
|
||||
public async receiver (message) {
|
||||
const event = JSON.parse(Buffer.from(message.data, 'binary').toString());
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ export class AskDialog extends IGBDialog {
|
|||
|
||||
// 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) {
|
||||
return nextDialog;
|
||||
}
|
||||
|
|
|
@ -307,8 +307,7 @@ export class KBService implements IGBKBService {
|
|||
top: 1
|
||||
});
|
||||
|
||||
const values = results.results; // TODO: See.
|
||||
|
||||
const values = results.results;
|
||||
let returnedScore = 0;
|
||||
|
||||
// Searches via Search (Azure Search).
|
||||
|
@ -542,7 +541,8 @@ export class KBService implements IGBKBService {
|
|||
};
|
||||
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 });
|
||||
// }
|
||||
// lastAnswer = answer1;
|
||||
|
@ -648,7 +648,7 @@ export class KBService implements IGBKBService {
|
|||
format: '.md',
|
||||
media: file.name,
|
||||
packageId: packageId,
|
||||
prevId: 0 // TODO: Calculate total rows and increment.
|
||||
prevId: 0 // https://github.com/GeneralBots/BotServer/issues/312
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ export class ProfileDialog extends IGBDialog {
|
|||
let phoneNumber;
|
||||
try {
|
||||
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);
|
||||
} catch (error) {
|
||||
await step.context.sendActivity(Messages[locale].validation_enter_valid_mobile);
|
||||
|
|
|
@ -130,10 +130,6 @@ export class WhatsappDirectLine extends GBService {
|
|||
case 'GeneralBots':
|
||||
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.
|
||||
|
||||
const gbaiName = `${this.min.botId}.gbai`;
|
||||
|
@ -251,7 +247,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
await createClient.bind(this)(this.browserWSEndpoint);
|
||||
|
||||
setUrl = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'chatapi':
|
||||
|
@ -542,7 +538,9 @@ export class WhatsappDirectLine extends GBService {
|
|||
await this.min.conversationalService.sendMarkdownToMobile(this.min, null, user.userSystemId, message);
|
||||
}
|
||||
} else if (text === '/qt') {
|
||||
// TODO: Transfers only in pt-br for now.
|
||||
|
||||
// https://github.com/GeneralBots/BotServer/issues/307
|
||||
|
||||
await this.sendToDeviceEx(
|
||||
manualUser.userSystemId,
|
||||
Messages[this.locale].notify_end_transfer(this.min.instance.botId),
|
||||
|
|
Loading…
Add table
Reference in a new issue