Skip to content

Commit

Permalink
feat(core.gbapp): New global quit keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Rodriguez (pragmatismo.io) committed Jul 4, 2019
1 parent ee3e7ec commit 15cd8d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 8 additions & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;

Expand All @@ -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');

Expand Down
9 changes: 6 additions & 3 deletions packages/core.gbapp/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ 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...',
good_morning: 'bom dia',
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.'
}
};

0 comments on commit 15cd8d6

Please sign in to comment.