Skip to content

Commit

Permalink
fix(basic.gblib): TODO removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Dec 26, 2022
1 parent dc94816 commit 2b08965
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1",
"c3-chart-maker": "0.2.8",
"chatgpt": "2.4.2",
"chrome-remote-interface": "0.31.3",
Expand Down
11 changes: 7 additions & 4 deletions packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ export class DialogKeywords {
}
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 {
Expand Down Expand Up @@ -1002,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);
Expand All @@ -1020,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);
}
}

Expand Down Expand Up @@ -1053,7 +1056,7 @@ export class DialogKeywords {

private static getChannel(): string {
return 'whatsapp';
// TODO:
// https://github.com/GeneralBots/BotServer/issues/309
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/basic.gblib/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down
10 changes: 3 additions & 7 deletions packages/basic.gblib/services/SystemKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class SystemKeywords {
}

public async callVM ({ text }) {
// TODO:

const min = null;
const step = null;
const deployer = null;
Expand Down Expand Up @@ -651,7 +651,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];
Expand Down Expand Up @@ -1279,7 +1278,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;
Expand All @@ -1293,10 +1292,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 {
Expand Down
4 changes: 3 additions & 1 deletion packages/basic.gblib/services/WebAutomationKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion packages/boot.gbot/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"enabledAdmin": "true",
"searchScore": ".45",
"nlpScore": ".80",
"nlpVsSearch": ".4",
"state":"active",
"autoPackageSync": "gbdialog, gbot, gbtheme"
}
3 changes: 0 additions & 3 deletions packages/core.gbapp/models/GBModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
16 changes: 6 additions & 10 deletions packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}
});
}
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 8 additions & 6 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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;

Expand All @@ -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.

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -1080,7 +1083,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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion packages/kb.gbapp/dialogs/AskDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/security.gbapp/dialogs/ProfileDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,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),
Expand Down

0 comments on commit 2b08965

Please sign in to comment.