feat(core.gbapp): New global quit keywords.
This commit is contained in:
parent
ee3e7ec0f9
commit
15cd8d6093
2 changed files with 14 additions and 4 deletions
|
@ -244,7 +244,7 @@ export class GBMinService {
|
||||||
if (instance !== null) {
|
if (instance !== null) {
|
||||||
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
|
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
|
||||||
let theme = instance.theme;
|
let theme = instance.theme;
|
||||||
if (theme !== undefined) {
|
if (theme === undefined) {
|
||||||
theme = 'default.gbtheme';
|
theme = 'default.gbtheme';
|
||||||
}
|
}
|
||||||
res.send(
|
res.send(
|
||||||
|
@ -485,6 +485,10 @@ export class GBMinService {
|
||||||
|
|
||||||
private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) {
|
private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) {
|
||||||
// Direct script invoking by itent name.
|
// 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;
|
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) === '/') {
|
} else if (context.activity.text.charAt(0) === '/') {
|
||||||
await step.beginDialog(context.activity.text);
|
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') {
|
} else if (context.activity.text === 'admin') {
|
||||||
await step.beginDialog('/admin');
|
await step.beginDialog('/admin');
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@ export const Messages = {
|
||||||
good_evening: 'good evening',
|
good_evening: 'good evening',
|
||||||
good_night: 'good night',
|
good_night: 'good night',
|
||||||
hi: (msg) => `Hello, ${msg}.`,
|
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': {
|
'pt-BR': {
|
||||||
show_video: 'Vou te mostrar um vídeo. Por favor, aguarde...',
|
show_video: 'Vou te mostrar um vídeo. Por favor, aguarde...',
|
||||||
|
@ -15,6 +16,8 @@ export const Messages = {
|
||||||
good_evening: 'boa tarde',
|
good_evening: 'boa tarde',
|
||||||
good_night: 'boa noite',
|
good_night: 'boa noite',
|
||||||
hi: (msg) => `Oi, ${msg}.`,
|
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.'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue