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 {
|
||||
|
||||
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
|
||||
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
|
||||
process.env.PWD = __dirname;
|
||||
|
|
|
@ -698,11 +698,10 @@ export class DialogKeywords {
|
|||
|
||||
// Handles SEND FILE TO mobile, element in Web Automation.
|
||||
|
||||
|
||||
const page = filename._page;
|
||||
if (page) {
|
||||
const gbaiName = `${this.min.botId}.gbai`;
|
||||
const localName = Path.join( 'work', gbaiName,'cache', `img${GBAdminService.getRndReadableIdentifier()}.jpg`);
|
||||
const localName = Path.join('work', gbaiName, 'cache', `img${GBAdminService.getRndReadableIdentifier()}.jpg`);
|
||||
await filename.screenshot({ path: localName });
|
||||
|
||||
const url = urlJoin(
|
||||
|
|
|
@ -51,7 +51,7 @@ const textract = require('textract');
|
|||
const walkPromise = require('walk-promise');
|
||||
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
||||
const phone = require('phone');
|
||||
|
||||
const Path = require('path');
|
||||
/**
|
||||
* @fileoverview Virtualization services for emulation of BASIC.
|
||||
* This alpha version is using a hack in form of converter to
|
||||
|
@ -311,7 +311,7 @@ export class GBVMService extends GBService {
|
|||
if ($2.indexOf('http') !== -1) {
|
||||
return `${$1} = sys().getByHttp (${$2}, headers, httpUsername, httpPs)`;
|
||||
} else {
|
||||
const count=($2.match(/\,/g) || []).length;
|
||||
const count = ($2.match(/\,/g) || []).length;
|
||||
const values = $2.split(',');
|
||||
|
||||
// Handles GET page, "selector".
|
||||
|
@ -458,7 +458,35 @@ export class GBVMService extends GBService {
|
|||
|
||||
// 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 vbsFile = `${filename}.compiled`;
|
||||
fs.writeFileSync(vbsFile, vbsCode, 'utf8');
|
||||
|
|
Loading…
Add table
Reference in a new issue