fix(core.gbapp): BASIC fixed on WhatsApp channel.

This commit is contained in:
Rodrigo Rodriguez 2020-06-05 14:40:21 -03:00
parent c36640e519
commit 1d316ef83b
4 changed files with 13 additions and 9 deletions

View file

@ -349,6 +349,7 @@ export class GBVMService extends GBService {
step.activeDialog.state.options = {}; step.activeDialog.state.options = {};
step.activeDialog.state.options.cbId = (step.options as any).id; step.activeDialog.state.options.cbId = (step.options as any).id;
step.activeDialog.state.options.previousResolve = (step.options as any).previousResolve; step.activeDialog.state.options.previousResolve = (step.options as any).previousResolve;
GBLog.info('BASIC: Asking for input (HEAR).');
return await min.conversationalService.prompt(min, step, null); return await min.conversationalService.prompt(min, step, null);
}, },
async step => { async step => {

View file

@ -236,12 +236,12 @@ export class AskDialog extends IGBDialog {
if (answer.content.endsWith('.docx')) { if (answer.content.endsWith('.docx')) {
const mainName = answer.content.replace(/\s|\-/gi, '').split('.')[0]; const mainName = answer.content.replace(/\s|\-/gi, '').split('.')[0];
await GBMinService.callVM(mainName, min, step); return await GBMinService.callVM(mainName, min, step);
} else { } else {
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer); await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
}
return await step.replaceDialog('/ask', { isReturning: true }); return await step.replaceDialog('/ask', { isReturning: true });
}
} }

View file

@ -431,7 +431,9 @@ export class KBService implements IGBKBService {
}); });
// MSFT Translator breaks markdown, so we need to fix it: // MSFT Translator breaks markdown, so we need to fix it:
text = text.replace('! [', '![').replace('] (','](');
text = text.replace('! [', '![').replace('] (', '](');
text = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', ''); // TODO: Improve it.
const html = marked(text); const html = marked(text);

View file

@ -427,14 +427,15 @@ export class WhatsappDirectLine extends GBService {
await this.sendToDevice(to, text); await this.sendToDevice(to, text);
} }
public async sendToDevice(to, msg) { public async sendToDevice(to, msg) {
const cmd = '/audio '; const cmd = '/audio ';
if (msg.startsWith(cmd)) { if (msg.startsWith(cmd)) {
msg = msg.substr(cmd.length); msg = msg.substr(cmd.length);
return await this.sendTextAsAudioToDevice(to, msg); return await this.sendTextAsAudioToDevice(to, msg);
} } else {
else {
const options = { const options = {
method: 'POST', method: 'POST',