fix(core.gbapp): Fix in launch of start dialog.
This commit is contained in:
parent
3d90bd872e
commit
dd40f32cf3
6 changed files with 15 additions and 42 deletions
|
@ -55,7 +55,7 @@ const phone = require('phone');
|
||||||
* @fileoverview Virtualization services for emulation of BASIC.
|
* @fileoverview Virtualization services for emulation of BASIC.
|
||||||
* This alpha version is using a hack in form of converter to
|
* This alpha version is using a hack in form of converter to
|
||||||
* translate BASIC to TS and string replacements to emulate await code.
|
* translate BASIC to TS and string replacements to emulate await code.
|
||||||
* See http://jsfiddle.net/roderick/dym05hsy for more info on vb2ts, so
|
* See https://github.com/uweg/vbscript-to-typescript for more info on vb2ts, so
|
||||||
* http://stevehanov.ca/blog/index.php?id=92 should be used to run it without
|
* http://stevehanov.ca/blog/index.php?id=92 should be used to run it without
|
||||||
* translation and enhance classic BASIC experience.
|
* translation and enhance classic BASIC experience.
|
||||||
*/
|
*/
|
||||||
|
@ -326,6 +326,7 @@ export class GBVMService extends GBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeBASIC(filename: any, min: GBMinInstance, deployer: GBDeployer, mainName: string) {
|
public async executeBASIC(filename: any, min: GBMinInstance, deployer: GBDeployer, mainName: string) {
|
||||||
|
|
||||||
// Converts General Bots BASIC into regular VBS
|
// Converts General Bots BASIC into regular VBS
|
||||||
|
|
||||||
const basicCode: string = fs.readFileSync(filename, 'utf8');
|
const basicCode: string = fs.readFileSync(filename, 'utf8');
|
||||||
|
@ -334,18 +335,20 @@ export class GBVMService extends GBService {
|
||||||
fs.writeFileSync(vbsFile, vbsCode, 'utf8');
|
fs.writeFileSync(vbsFile, vbsCode, 'utf8');
|
||||||
|
|
||||||
// Converts VBS into TS.
|
// Converts VBS into TS.
|
||||||
|
|
||||||
vb2ts.convertFile(vbsFile);
|
vb2ts.convertFile(vbsFile);
|
||||||
|
|
||||||
// Convert TS into JS.
|
// Convert TS into JS.
|
||||||
|
|
||||||
const tsfile: string = `${filename}.ts`;
|
const tsfile: string = `${filename}.ts`;
|
||||||
let tsCode: string = fs.readFileSync(tsfile, 'utf8');
|
let tsCode: string = fs.readFileSync(tsfile, 'utf8');
|
||||||
tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve;`);
|
tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve;`);
|
||||||
fs.writeFileSync(tsfile, tsCode);
|
fs.writeFileSync(tsfile, tsCode);
|
||||||
|
|
||||||
const tsc = new TSCompiler();
|
const tsc = new TSCompiler();
|
||||||
tsc.compile([tsfile]);
|
tsc.compile([tsfile]);
|
||||||
|
|
||||||
// Run JS into the GB context.
|
// Run JS into the GB context.
|
||||||
|
|
||||||
const jsfile = `${tsfile}.js`.replace('.ts', '');
|
const jsfile = `${tsfile}.js`.replace('.ts', '');
|
||||||
|
|
||||||
if (fs.existsSync(jsfile)) {
|
if (fs.existsSync(jsfile)) {
|
||||||
|
@ -431,7 +434,7 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
private executeJS(min: GBMinInstance, deployer: GBDeployer, parsedCode: string, mainName: string) {
|
private executeJS(min: GBMinInstance, deployer: GBDeployer, parsedCode: string, mainName: string) {
|
||||||
try {
|
try {
|
||||||
min.sandBoxMap[mainName.toLowerCase()] = parsedCode;
|
min.sandBoxMap[mainName.toLowerCase().trim()] = parsedCode;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`[GBVMService] ERROR loading ${error}`);
|
GBLog.error(`[GBVMService] ERROR loading ${error}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Source: https://github.com/uweg/vbscript-to-typescript
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
exports.__esModule = true;
|
||||||
var fs_1 = require("fs");
|
var fs_1 = require("fs");
|
||||||
|
|
|
@ -388,30 +388,6 @@ export class GBConversationalService {
|
||||||
GBLog.error(error);
|
GBLog.error(error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
// let pushStream = sdk.AudioInputStream.createPushStream();
|
|
||||||
// pushStream.write(data);
|
|
||||||
// pushStream.close();
|
|
||||||
|
|
||||||
// let audioConfig = sdk.AudioConfig.fromStreamInput(pushStream);
|
|
||||||
// let speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);
|
|
||||||
// speechConfig.speechRecognitionLanguage = locale;
|
|
||||||
// let recognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);
|
|
||||||
|
|
||||||
// recognizer.recognizeOnceAsync(
|
|
||||||
// (result) => {
|
|
||||||
|
|
||||||
// resolve(result.text ? result.text : 'Speech to Text failed: Audio not converted');
|
|
||||||
|
|
||||||
// recognizer.close();
|
|
||||||
// recognizer = undefined;
|
|
||||||
// },
|
|
||||||
// (err) => {
|
|
||||||
// reject(err);
|
|
||||||
|
|
||||||
// recognizer.close();
|
|
||||||
// recognizer = undefined;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -616,6 +616,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
const vm = new GBVMService();
|
const vm = new GBVMService();
|
||||||
await vm.loadDialogPackage(localPath, min, this.core, this);
|
await vm.loadDialogPackage(localPath, min, this.core, this);
|
||||||
|
GBLog.info(`Dialogs (.gbdialog) for ${min.botId} loaded.`);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '.gbtheme':
|
case '.gbtheme':
|
||||||
|
|
|
@ -341,19 +341,11 @@ export class GBMinService {
|
||||||
const instance = await this.core.loadInstanceByBotId(activeMin.botId);
|
const instance = await this.core.loadInstanceByBotId(activeMin.botId);
|
||||||
await sec.updateUserInstance(id, instance.instanceId);
|
await sec.updateUserInstance(id, instance.instanceId);
|
||||||
await (activeMin as any).whatsAppDirectLine.resetConversationId(id);
|
await (activeMin as any).whatsAppDirectLine.resetConversationId(id);
|
||||||
const startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
|
|
||||||
GBLog.info(`Auto start (2) dialog is now being called: ${startDialog} for ${activeMin.instance.botId}...`);
|
|
||||||
|
|
||||||
if (startDialog) {
|
|
||||||
req.body.messages[0].body = `/call ${startDialog}`;
|
|
||||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
|
||||||
} else {
|
|
||||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(
|
await (activeMin as any).whatsAppDirectLine.sendToDevice(
|
||||||
id,
|
id,
|
||||||
`Agora falando com ${activeMin.instance.title}...`
|
`Agora falando com ${activeMin.instance.title}...`
|
||||||
);
|
);
|
||||||
res.end();
|
res.end();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
|
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
|
||||||
if (activeMin === undefined) {
|
if (activeMin === undefined) {
|
||||||
|
@ -820,8 +812,7 @@ export class GBMinService {
|
||||||
// Skips if the bot is talking.
|
// Skips if the bot is talking.
|
||||||
|
|
||||||
if (context.activity.type === 'conversationUpdate' &&
|
if (context.activity.type === 'conversationUpdate' &&
|
||||||
context.activity.membersAdded.length > 0 &&
|
context.activity.membersAdded.length > 0) {
|
||||||
context.activity.membersAdded[0].id.indexOf(min.botId) == -1) {
|
|
||||||
|
|
||||||
// Check if a bot or a human participant is being added to the conversation.
|
// Check if a bot or a human participant is being added to the conversation.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
' General Bots Copyright (c) Pragmatismo.io. All rights reserved. Licensed under the AGPL-3.0.
|
' General Bots Copyright (c) Pragmatismo.io. All rights reserved. Licensed under the AGPL-3.0.
|
||||||
|
' Rules from http://jsfiddle.net/roderick/dym05hsy
|
||||||
|
|
||||||
talk "How many installments do you want to pay your Credit?"
|
talk "How many installments do you want to pay your Credit?"
|
||||||
hear installments
|
hear installments
|
||||||
|
|
Loading…
Add table
Reference in a new issue