fix(basic.gblib): Dialogs are now ending OK.
This commit is contained in:
parent
a6d1f90bbf
commit
c1fe708aa7
3 changed files with 18 additions and 15 deletions
|
@ -58,13 +58,16 @@ export class DialogKeywords {
|
||||||
*/
|
*/
|
||||||
public internalSys: SystemKeywords;
|
public internalSys: SystemKeywords;
|
||||||
|
|
||||||
|
private user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When creating this keyword facade, a bot instance is
|
* When creating this keyword facade, a bot instance is
|
||||||
* specified among the deployer service.
|
* specified among the deployer service.
|
||||||
*/
|
*/
|
||||||
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep) {
|
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep, user) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.internalSys = new SystemKeywords(min, deployer, step);
|
this.internalSys = new SystemKeywords(min, deployer, user);
|
||||||
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -698,7 +698,9 @@ export class GBVMService extends GBService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const opts = await promise(step, result);
|
const opts = await promise(step, result);
|
||||||
return await step.replaceDialog('/hear', opts);
|
if (Object.keys(min.cbMap).length) {
|
||||||
|
return await step.replaceDialog('/hear', opts);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error in BASIC code: ${error}`);
|
GBLog.error(`Error in BASIC code: ${error}`);
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
@ -718,13 +720,14 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
// Creates a class DialogKeywords which is the *this* pointer
|
// Creates a class DialogKeywords which is the *this* pointer
|
||||||
// in BASIC.
|
// in BASIC.
|
||||||
|
const user = await min.userProfile.get(step.context, {});
|
||||||
const sandbox: DialogKeywords = new DialogKeywords(min, deployer, step);
|
const sandbox: DialogKeywords = new DialogKeywords(min, deployer, step, user);
|
||||||
|
|
||||||
// Injects the .gbdialog generated code into the VM.
|
// Injects the .gbdialog generated code into the VM.
|
||||||
|
|
||||||
const context = vm.createContext(sandbox);
|
const context = vm.createContext(sandbox);
|
||||||
const code = min.sandBoxMap[text];
|
const code = min.sandBoxMap[text];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
vm.runInContext(code, context);
|
vm.runInContext(code, context);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -60,17 +60,14 @@ export class SystemKeywords {
|
||||||
*/
|
*/
|
||||||
private readonly deployer: GBDeployer;
|
private readonly deployer: GBDeployer;
|
||||||
|
|
||||||
/**
|
private user;
|
||||||
* Reference to the deployer service.
|
|
||||||
*/
|
|
||||||
private readonly step: GBDialogStep;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When creating this keyword facade, a bot instance is
|
* When creating this keyword facade, a bot instance is
|
||||||
* specified among the deployer service.
|
* specified among the deployer service.
|
||||||
*/
|
*/
|
||||||
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep) {
|
constructor(min: GBMinInstance, deployer: GBDeployer, user) {
|
||||||
this.step = step;
|
this.user = user;
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.deployer = deployer;
|
this.deployer = deployer;
|
||||||
}
|
}
|
||||||
|
@ -291,11 +288,11 @@ export class SystemKeywords {
|
||||||
throw `File '${file}' has a FIND call with more than 1 arguments. Check the .gbdialog associated.`;
|
throw `File '${file}' has a FIND call with more than 1 arguments. Check the .gbdialog associated.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await this.min.userProfile.get(this.step.context, {});
|
|
||||||
let maxLines = 100;
|
let maxLines = 100;
|
||||||
if (user.basicOptions && user.basicOptions.maxLines) {
|
if (this.user.basicOptions && this.user.basicOptions.maxLines) {
|
||||||
if (user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
|
if (this.user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
|
||||||
maxLines = Number.parseInt(user.basicOptions.maxLines).valueOf();
|
maxLines = Number.parseInt(this.user.basicOptions.maxLines).valueOf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue