feat(core.gbapp): New global quit keywords.

This commit is contained in:
Rodrigo Rodriguez (pragmatismo.io) 2019-07-04 15:14:26 -03:00
parent ee3e7ec0f9
commit 15cd8d6093
2 changed files with 14 additions and 4 deletions

View file

@ -244,7 +244,7 @@ export class GBMinService {
if (instance !== null) {
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
let theme = instance.theme;
if (theme !== undefined) {
if (theme === undefined) {
theme = 'default.gbtheme';
}
res.send(
@ -485,6 +485,10 @@ export class GBMinService {
private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) {
// Direct script invoking by itent name.
const globalQuit = (locale, utterance) => {
return utterance.match(Messages[locale].global_quit);
}
const isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined;
@ -498,6 +502,9 @@ export class GBMinService {
} else if (context.activity.text.charAt(0) === '/') {
await step.beginDialog(context.activity.text);
} else if (globalQuit(step.context.activity.locale, context.activity.text)) {
await step.cancelAllDialogs();
await step.context.sendActivity(Messages[step.context.activity.locale].canceled);
} else if (context.activity.text === 'admin') {
await step.beginDialog('/admin');

View file

@ -6,8 +6,9 @@ export const Messages = {
good_evening: 'good evening',
good_night: 'good night',
hi: (msg) => `Hello, ${msg}.`,
very_sorry_about_error: `I'm sorry to inform that there was an error which was recorded to be solved.`
very_sorry_about_error: `I'm sorry to inform that there was an error which was recorded to be solved.`,
global_quit: /^(quit|Quit)/i,
canceled: 'Canceled. If I can be useful, let me know how'
},
'pt-BR': {
show_video: 'Vou te mostrar um vídeo. Por favor, aguarde...',
@ -15,6 +16,8 @@ export const Messages = {
good_evening: 'boa tarde',
good_night: 'boa noite',
hi: (msg) => `Oi, ${msg}.`,
very_sorry_about_error: `Lamento, ocorreu um erro que já foi registrado para ser tratado.`
very_sorry_about_error: `Lamento, ocorreu um erro que já foi registrado para ser tratado.`,
global_quit: /^(sair|Sair)/i,
canceled: 'Cancelado, avise como posso ser útil novamente.'
}
};