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;
|
||||
|
||||
private user;
|
||||
|
||||
/**
|
||||
* When creating this keyword facade, a bot instance is
|
||||
* specified among the deployer service.
|
||||
*/
|
||||
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep) {
|
||||
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep, user) {
|
||||
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);
|
||||
return await step.replaceDialog('/hear', opts);
|
||||
if (Object.keys(min.cbMap).length) {
|
||||
return await step.replaceDialog('/hear', opts);
|
||||
}
|
||||
} catch (error) {
|
||||
GBLog.error(`Error in BASIC code: ${error}`);
|
||||
const locale = step.context.activity.locale;
|
||||
|
@ -718,13 +720,14 @@ export class GBVMService extends GBService {
|
|||
|
||||
// Creates a class DialogKeywords which is the *this* pointer
|
||||
// in BASIC.
|
||||
|
||||
const sandbox: DialogKeywords = new DialogKeywords(min, deployer, step);
|
||||
const user = await min.userProfile.get(step.context, {});
|
||||
const sandbox: DialogKeywords = new DialogKeywords(min, deployer, step, user);
|
||||
|
||||
// Injects the .gbdialog generated code into the VM.
|
||||
|
||||
const context = vm.createContext(sandbox);
|
||||
const code = min.sandBoxMap[text];
|
||||
|
||||
try {
|
||||
vm.runInContext(code, context);
|
||||
} catch (error) {
|
||||
|
|
|
@ -60,17 +60,14 @@ export class SystemKeywords {
|
|||
*/
|
||||
private readonly deployer: GBDeployer;
|
||||
|
||||
/**
|
||||
* Reference to the deployer service.
|
||||
*/
|
||||
private readonly step: GBDialogStep;
|
||||
private user;
|
||||
|
||||
/**
|
||||
* When creating this keyword facade, a bot instance is
|
||||
* specified among the deployer service.
|
||||
*/
|
||||
constructor(min: GBMinInstance, deployer: GBDeployer, step: GBDialogStep) {
|
||||
this.step = step;
|
||||
constructor(min: GBMinInstance, deployer: GBDeployer, user) {
|
||||
this.user = user;
|
||||
this.min = min;
|
||||
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.`;
|
||||
}
|
||||
|
||||
const user = await this.min.userProfile.get(this.step.context, {});
|
||||
|
||||
let maxLines = 100;
|
||||
if (user.basicOptions && user.basicOptions.maxLines) {
|
||||
if (user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
|
||||
maxLines = Number.parseInt(user.basicOptions.maxLines).valueOf();
|
||||
if (this.user.basicOptions && this.user.basicOptions.maxLines) {
|
||||
if (this.user.basicOptions.maxLines.toString().toLowerCase() !== "default") {
|
||||
maxLines = Number.parseInt(this.user.basicOptions.maxLines).valueOf();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue