From 565f200ebfd221101c2a97500a136e55f064ef45 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sat, 18 Sep 2021 09:41:18 -0300 Subject: [PATCH] fix(basic.gblib): Goto dialog within web. --- .../basic.gblib/services/DialogKeywords.ts | 20 +++++++++++-------- packages/basic.gblib/services/GBVMService.ts | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 503addbe..4b6cddab 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -453,18 +453,22 @@ export class DialogKeywords { /** * Prepares the next dialog to be shown to the specified user. */ - public async gotoDialog(step, fromOrDialogName: string, dialogName: string) { + public async gotoDialog(step, fromOrDialogName: string, dialogName: string) { if (dialogName) { - let sec = new SecService(); - let user = await sec.getUserFromSystemId(fromOrDialogName); - if (!user) { - user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName, - fromOrDialogName, null, 'whatsapp', 'from', null); + if (dialogName.charAt(0) === '/') { + await step.beginDialog(fromOrDialogName); + } else { + let sec = new SecService(); + let user = await sec.getUserFromSystemId(fromOrDialogName); + if (!user) { + user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName, + fromOrDialogName, null, 'whatsapp', 'from', null); + } + await sec.updateUserHearOnDialog(user.userId, dialogName); } - await sec.updateUserHearOnDialog(user.userId, dialogName); } else { - await step.beginDialog(dialogName); + await step.beginDialog(fromOrDialogName); } } diff --git a/packages/basic.gblib/services/GBVMService.ts b/packages/basic.gblib/services/GBVMService.ts index e75dc160..f8834ca6 100644 --- a/packages/basic.gblib/services/GBVMService.ts +++ b/packages/basic.gblib/services/GBVMService.ts @@ -242,7 +242,7 @@ export class GBVMService extends GBService { }); code = code.replace(/(go to)(\s)(.*)/gi, ($0, $1, $2, $3) => { - return `sys().gotoDialog(step, ${$3})\n`; + return `gotoDialog(step, ${$3})\n`; }); code = code.replace(/(hear)\s*(\w+)/gi, ($0, $1, $2) => {