Skip to content

Commit

Permalink
fix(core.gbapp): Any question can be forwarded to .docx dialogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 6, 2020
1 parent db6fd3e commit 4f3ada1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/admin.gbapp/dialogs/AdminDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class AdminDialog extends IGBDialog {
await min.conversationalService.sendText(min, step, Messages[locale].finished_working);
}
} catch (error) {
await min.conversationalService.sendText(min, step, error.message);
await min.conversationalService.sendText(min, step, error.message?error.message: error);
}
await step.replaceDialog('/ask', { isReturning: true });
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class GBDeployer implements IGBDeployer {
}

public static getConnectionStringFromInstance(instance: IGBInstance) {
return `Server=tcp:${instance.storageServer}.database.windows.net,1433;Database=${instance.storageName};User ID=${instance.storageUsername};Password=${instance.storagePassword};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;`;
return `Server=tcp:${instance.storageServer},1433;Database=${instance.storageName};User ID=${instance.storageUsername};Password=${instance.storagePassword};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;`;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ export class GBVMService extends GBService {

filename = vbsFile;

let mainName = filename.replace(/\s|\-/gi, '').split('.')[0];
mainName = mainName.toLowerCase();
min.scriptMap[filename] = mainName.toLowerCase();
let mainName = GBVMService.getMethodNameFromVBSFilename(filename);
min.scriptMap[filename] = mainName;

const fullFilename = urlJoin(folder, filename);
// TODO: Implement in development mode, how swap for .vbs files
Expand All @@ -122,6 +121,11 @@ export class GBVMService extends GBService {
});
}

public static getMethodNameFromVBSFilename(filename: string) {
let mainName = filename.replace(/\s|\-/gi, '').split('.')[0];
return mainName.toLowerCase();
}

private async getTextFromWord(folder: string, filename: string) {
return new Promise<string>(async (resolve, reject) => {
textract.fromFileWithPath(urlJoin(folder, filename), { preserveLineBreaks: true }, (error, text) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/kb.gbapp/dialogs/AskDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ export class AskDialog extends IGBDialog {
}

private static async handleAnswer(service: KBService, min: GBMinInstance, step: any, answer: GuaribasAnswer) {
if (answer.content.endsWith('.docx')) {
const mainName = answer.content.replace(/\s|\-/gi, '').split('.')[0];
const text = answer.content
if (text.endsWith('.docx')) {
const mainName = GBVMService.getMethodNameFromVBSFilename(text);
return await GBVMService.callVM(mainName, min, step, this.deployer);
} else {
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
Expand Down

0 comments on commit 4f3ada1

Please sign in to comment.