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.
|
||||
* This alpha version is using a hack in form of converter to
|
||||
* 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
|
||||
* 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) {
|
||||
|
||||
// Converts General Bots BASIC into regular VBS
|
||||
|
||||
const basicCode: string = fs.readFileSync(filename, 'utf8');
|
||||
|
@ -334,18 +335,20 @@ export class GBVMService extends GBService {
|
|||
fs.writeFileSync(vbsFile, vbsCode, 'utf8');
|
||||
|
||||
// Converts VBS into TS.
|
||||
|
||||
vb2ts.convertFile(vbsFile);
|
||||
|
||||
// Convert TS into JS.
|
||||
|
||||
const tsfile: string = `${filename}.ts`;
|
||||
let tsCode: string = fs.readFileSync(tsfile, 'utf8');
|
||||
tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve;`);
|
||||
fs.writeFileSync(tsfile, tsCode);
|
||||
|
||||
const tsc = new TSCompiler();
|
||||
tsc.compile([tsfile]);
|
||||
|
||||
// Run JS into the GB context.
|
||||
|
||||
const jsfile = `${tsfile}.js`.replace('.ts', '');
|
||||
|
||||
if (fs.existsSync(jsfile)) {
|
||||
|
@ -431,7 +434,7 @@ export class GBVMService extends GBService {
|
|||
|
||||
private executeJS(min: GBMinInstance, deployer: GBDeployer, parsedCode: string, mainName: string) {
|
||||
try {
|
||||
min.sandBoxMap[mainName.toLowerCase()] = parsedCode;
|
||||
min.sandBoxMap[mainName.toLowerCase().trim()] = parsedCode;
|
||||
} catch (error) {
|
||||
GBLog.error(`[GBVMService] ERROR loading ${error}`);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Source: https://github.com/uweg/vbscript-to-typescript
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var fs_1 = require("fs");
|
||||
|
|
|
@ -388,30 +388,6 @@ export class GBConversationalService {
|
|||
GBLog.error(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) {
|
||||
|
|
|
@ -616,6 +616,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
const vm = new GBVMService();
|
||||
await vm.loadDialogPackage(localPath, min, this.core, this);
|
||||
GBLog.info(`Dialogs (.gbdialog) for ${min.botId} loaded.`);
|
||||
break;
|
||||
|
||||
case '.gbtheme':
|
||||
|
|
|
@ -341,19 +341,11 @@ export class GBMinService {
|
|||
const instance = await this.core.loadInstanceByBotId(activeMin.botId);
|
||||
await sec.updateUserInstance(id, instance.instanceId);
|
||||
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(
|
||||
id,
|
||||
`Agora falando com ${activeMin.instance.title}...`
|
||||
);
|
||||
res.end();
|
||||
}
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(
|
||||
id,
|
||||
`Agora falando com ${activeMin.instance.title}...`
|
||||
);
|
||||
res.end();
|
||||
} else {
|
||||
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
|
||||
if (activeMin === undefined) {
|
||||
|
@ -820,8 +812,7 @@ export class GBMinService {
|
|||
// Skips if the bot is talking.
|
||||
|
||||
if (context.activity.type === 'conversationUpdate' &&
|
||||
context.activity.membersAdded.length > 0 &&
|
||||
context.activity.membersAdded[0].id.indexOf(min.botId) == -1) {
|
||||
context.activity.membersAdded.length > 0) {
|
||||
|
||||
// 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.
|
||||
' Rules from http://jsfiddle.net/roderick/dym05hsy
|
||||
|
||||
talk "How many installments do you want to pay your Credit?"
|
||||
hear installments
|
||||
|
|
Loading…
Add table
Reference in a new issue