new(all): EXIT and INCLUDE keywords improved and introduced.
This commit is contained in:
parent
465f0db5a0
commit
846f117f61
3 changed files with 40 additions and 13 deletions
2
boot.js
2
boot.js
|
@ -23,7 +23,7 @@ var now = () => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var run = () => {
|
var run = () => {
|
||||||
console.log(`[GB Runtime] Initializing General Bots Server...`);
|
console.log(`[GB Runtime] Initializing General Bots (BotServer)...`);
|
||||||
const GBServer = require("./dist/src/app").GBServer
|
const GBServer = require("./dist/src/app").GBServer
|
||||||
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
|
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
|
||||||
process.env.PWD = __dirname;
|
process.env.PWD = __dirname;
|
||||||
|
|
|
@ -698,7 +698,6 @@ export class DialogKeywords {
|
||||||
|
|
||||||
// Handles SEND FILE TO mobile, element in Web Automation.
|
// Handles SEND FILE TO mobile, element in Web Automation.
|
||||||
|
|
||||||
|
|
||||||
const page = filename._page;
|
const page = filename._page;
|
||||||
if (page) {
|
if (page) {
|
||||||
const gbaiName = `${this.min.botId}.gbai`;
|
const gbaiName = `${this.min.botId}.gbai`;
|
||||||
|
|
|
@ -51,7 +51,7 @@ const textract = require('textract');
|
||||||
const walkPromise = require('walk-promise');
|
const walkPromise = require('walk-promise');
|
||||||
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
||||||
const phone = require('phone');
|
const phone = require('phone');
|
||||||
|
const Path = require('path');
|
||||||
/**
|
/**
|
||||||
* @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
|
||||||
|
@ -458,7 +458,35 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
// Converts General Bots BASIC into regular VBS
|
// Converts General Bots BASIC into regular VBS
|
||||||
|
|
||||||
const basicCode: string = fs.readFileSync(filename, 'utf8');
|
let basicCode: string = fs.readFileSync(filename, 'utf8');
|
||||||
|
|
||||||
|
// Processes EXIT keyword, removing extracode, useful
|
||||||
|
// for development.
|
||||||
|
|
||||||
|
let exit = /(\nexit\n)/gi.exec(basicCode);
|
||||||
|
if (exit) {
|
||||||
|
basicCode = basicCode.substring(0, exit.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process INCLUDE keyword to include another
|
||||||
|
// dialog inside the dialog.
|
||||||
|
let include = null;
|
||||||
|
do {
|
||||||
|
include = /^include\b(.*)$/gmi.exec(basicCode);
|
||||||
|
|
||||||
|
if (include) {
|
||||||
|
let includeName = include[1].trim();
|
||||||
|
includeName = Path.join(Path.dirname(filename), includeName);
|
||||||
|
includeName = includeName.substr(0, includeName.lastIndexOf(".")) + ".vbs";
|
||||||
|
|
||||||
|
// To use include, two /publish will be necessary (for now)
|
||||||
|
// because of alphabet order may raise not found errors.
|
||||||
|
|
||||||
|
let includeCode: string = fs.readFileSync(includeName, 'utf8');
|
||||||
|
basicCode = basicCode.replace(/^include\b.*$/gmi, includeCode);
|
||||||
|
}
|
||||||
|
} while (include);
|
||||||
|
|
||||||
const vbsCode = this.convertGBASICToVBS(basicCode);
|
const vbsCode = this.convertGBASICToVBS(basicCode);
|
||||||
const vbsFile = `${filename}.compiled`;
|
const vbsFile = `${filename}.compiled`;
|
||||||
fs.writeFileSync(vbsFile, vbsCode, 'utf8');
|
fs.writeFileSync(vbsFile, vbsCode, 'utf8');
|
||||||
|
|
Loading…
Add table
Reference in a new issue