fix(core.gbapp): Any question can be forwarded to .docx dialogs.

This commit is contained in:
Rodrigo Rodriguez 2020-11-06 17:06:22 -03:00
parent db6fd3e184
commit 4f3ada1902
4 changed files with 12 additions and 7 deletions

View file

@ -173,7 +173,7 @@ export class AdminDialog extends IGBDialog {
await min.conversationalService.sendText(min, step, Messages[locale].finished_working); await min.conversationalService.sendText(min, step, Messages[locale].finished_working);
} }
} catch (error) { } 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 }); await step.replaceDialog('/ask', { isReturning: true });
} }

View file

@ -74,7 +74,7 @@ export class GBDeployer implements IGBDeployer {
} }
public static getConnectionStringFromInstance(instance: IGBInstance) { 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;`;
} }
/** /**

View file

@ -93,9 +93,8 @@ export class GBVMService extends GBService {
filename = vbsFile; filename = vbsFile;
let mainName = filename.replace(/\s|\-/gi, '').split('.')[0]; let mainName = GBVMService.getMethodNameFromVBSFilename(filename);
mainName = mainName.toLowerCase(); min.scriptMap[filename] = mainName;
min.scriptMap[filename] = mainName.toLowerCase();
const fullFilename = urlJoin(folder, filename); const fullFilename = urlJoin(folder, filename);
// TODO: Implement in development mode, how swap for .vbs files // TODO: Implement in development mode, how swap for .vbs files
@ -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) { private async getTextFromWord(folder: string, filename: string) {
return new Promise<string>(async (resolve, reject) => { return new Promise<string>(async (resolve, reject) => {
textract.fromFileWithPath(urlJoin(folder, filename), { preserveLineBreaks: true }, (error, text) => { textract.fromFileWithPath(urlJoin(folder, filename), { preserveLineBreaks: true }, (error, text) => {

View file

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