fix(basic.gblib): #395 TALK with no quotes.
This commit is contained in:
parent
825d6c1a0f
commit
872471c13f
3 changed files with 62 additions and 58 deletions
|
@ -434,7 +434,7 @@ export class KeywordsExpressions {
|
||||||
/^\s*(.*)\=\s*(UPLOAD)(\s*)(.*)/gim,
|
/^\s*(.*)\=\s*(UPLOAD)(\s*)(.*)/gim,
|
||||||
($0, $1, $2, $3, $4) => {
|
($0, $1, $2, $3, $4) => {
|
||||||
const params = this.getParams($4, ['file']);
|
const params = this.getParams($4, ['file']);
|
||||||
return `await sys.uploadFile ({pid: pid, ${params}})`;
|
return `${$1} = await sys.uploadFile ({pid: pid, ${params}})`;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -909,13 +909,14 @@ export class KeywordsExpressions {
|
||||||
keywords[i++] = [
|
keywords[i++] = [
|
||||||
/^\s*(talk)(\s*)(.*)/gim,
|
/^\s*(talk)(\s*)(.*)/gim,
|
||||||
($0, $1, $2, $3) => {
|
($0, $1, $2, $3) => {
|
||||||
$3 = GBVMService.normalizeQuotes($3);
|
// Issue: #395
|
||||||
|
// $3 = GBVMService.normalizeQuotes($3);
|
||||||
|
|
||||||
// Uses auto quote if this is a frase with more then one word.
|
// // Uses auto quote if this is a phrase with more then one word.
|
||||||
|
|
||||||
if (/\s/.test($3) && $3.substr(0, 1) !== '"') {
|
// if (/\s/.test($3) && $3.substr(0, 1) !== '`') {
|
||||||
$3 = `"${$3}"`;
|
// $3 = "`" + $3 + "`";
|
||||||
}
|
// }
|
||||||
return `await dk.talk ({pid: pid, text: ${$3}})`;
|
return `await dk.talk ({pid: pid, text: ${$3}})`;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -664,7 +664,7 @@ export class SystemKeywords {
|
||||||
|
|
||||||
const accountName = min.core.getParam(min.instance, 'Blob Account');
|
const accountName = min.core.getParam(min.instance, 'Blob Account');
|
||||||
const accountKey = min.core.getParam(min.instance, 'Blob Key');
|
const accountKey = min.core.getParam(min.instance, 'Blob Key');
|
||||||
const blobName = min.core.getParam(min.instance, 'Blob Name');
|
|
||||||
const sharedKeyCredential = new StorageSharedKeyCredential(
|
const sharedKeyCredential = new StorageSharedKeyCredential(
|
||||||
accountName,
|
accountName,
|
||||||
accountKey
|
accountKey
|
||||||
|
@ -693,7 +693,7 @@ export class SystemKeywords {
|
||||||
// Performs uploading passing local hash.
|
// Performs uploading passing local hash.
|
||||||
|
|
||||||
const container = blobServiceClient.getContainerClient(accountName);
|
const container = blobServiceClient.getContainerClient(accountName);
|
||||||
const blockBlobClient: BlockBlobClient = container.getBlockBlobClient(blobName);
|
const blockBlobClient: BlockBlobClient = container.getBlockBlobClient(file.path);
|
||||||
const res = await blockBlobClient.uploadFile(localName,
|
const res = await blockBlobClient.uploadFile(localName,
|
||||||
{
|
{
|
||||||
blobHTTPHeaders: {
|
blobHTTPHeaders: {
|
||||||
|
@ -703,10 +703,11 @@ export class SystemKeywords {
|
||||||
|
|
||||||
// If upload is OK including hash check, removes the temporary file.
|
// If upload is OK including hash check, removes the temporary file.
|
||||||
|
|
||||||
if ((res._response.status === 200 || res._response.status === 201) && res.contentMD5 === hash) {
|
if (res._response.status === 201 &&
|
||||||
|
(new Uint8Array(res.contentMD5)).toString() === hash.toString()) {
|
||||||
Fs.rmSync(localName);
|
Fs.rmSync(localName);
|
||||||
|
|
||||||
file['md5'] = res.contentMD5;
|
file['md5'] = hash.toString();
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
|
@ -2546,20 +2547,20 @@ export class SystemKeywords {
|
||||||
return { contentType, ext, kind, category: kind['category'] };
|
return { contentType, ext, kind, category: kind['category'] };
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteFile({ min, file }) {
|
public async deleteFile({ pid, file }) {
|
||||||
// const file = GBServer.globals.files[handle];
|
const { min } = await DialogKeywords.getProcessInfo(pid);
|
||||||
GBLog.info(`BASIC: Auto saving '${file.filename}' (SAVE file).`);
|
GBLog.info(`BASIC: DELETE '${file.name}'.`);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
|
||||||
const path = DialogKeywords.getGBAIPath(min.botId, `gbdrive`);
|
const gbaiPath = DialogKeywords.getGBAIPath(min.botId);
|
||||||
const fileName = file.url ? file.url : file.name;
|
const fileName = file.name;
|
||||||
const contentType = mime.lookup(fileName);
|
const contentType = mime.lookup(fileName);
|
||||||
const ext = Path.extname(fileName).substring(1);
|
const ext = Path.extname(fileName).substring(1);
|
||||||
const kind = await this.getExtensionInfo(ext);
|
const kind = await this.getExtensionInfo(ext);
|
||||||
|
|
||||||
const result = await client
|
await client
|
||||||
.api(`${baseUrl}/drive/root:/${path}/${file}`)
|
.api(`${baseUrl}/drive/root:/${gbaiPath}/${file.path}`)
|
||||||
.delete(file.data);
|
.delete();
|
||||||
|
|
||||||
return { contentType, ext, kind, category: kind['category'] };
|
return { contentType, ext, kind, category: kind['category'] };
|
||||||
}
|
}
|
||||||
|
@ -2576,7 +2577,7 @@ export class SystemKeywords {
|
||||||
/**
|
/**
|
||||||
* Loads all para from tabular file Config.xlsx.
|
* Loads all para from tabular file Config.xlsx.
|
||||||
*/
|
*/
|
||||||
public async dirFolder({ pid, remotePath, baseUrl = null, array = null }) {
|
public async dirFolder({ pid, remotePath, baseUrl = null, client = null, array = null }) {
|
||||||
|
|
||||||
const { min } = await DialogKeywords.getProcessInfo(pid);
|
const { min } = await DialogKeywords.getProcessInfo(pid);
|
||||||
GBLogEx.info(min, `dirFolder: remotePath=${remotePath}, baseUrl=${baseUrl}`);
|
GBLogEx.info(min, `dirFolder: remotePath=${remotePath}, baseUrl=${baseUrl}`);
|
||||||
|
@ -2585,49 +2586,51 @@ export class SystemKeywords {
|
||||||
array = [];
|
array = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!baseUrl) {
|
if (!baseUrl){
|
||||||
|
let obj = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
baseUrl = obj.baseUrl;
|
||||||
|
client = obj.client;
|
||||||
|
}
|
||||||
|
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
remotePath = remotePath.replace(/\\/gi, '/');
|
||||||
|
|
||||||
remotePath = remotePath.replace(/\\/gi, '/');
|
// Retrieves all files in remote folder.
|
||||||
|
|
||||||
// Retrieves all files in remote folder.
|
let path = DialogKeywords.getGBAIPath(min.botId);
|
||||||
|
path = urlJoin(path, remotePath);
|
||||||
let path = DialogKeywords.getGBAIPath(min.botId);
|
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
||||||
path = urlJoin(path, remotePath);
|
|
||||||
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
|
||||||
|
|
||||||
const res = await client.api(url).get();
|
|
||||||
const documents = res.value;
|
|
||||||
if (documents === undefined || documents.length === 0) {
|
|
||||||
GBLogEx.info(min, `${remotePath} is an empty folder.`);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate files / directory to recurse.
|
|
||||||
|
|
||||||
await CollectionUtil.asyncForEach(documents, async item => {
|
|
||||||
|
|
||||||
if (item.folder) {
|
|
||||||
remotePath = urlJoin(remotePath, item.name);
|
|
||||||
array = [array, ... await this.dirFolder({ pid, remotePath, baseUrl, array })];
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// TODO: https://raw.githubusercontent.com/ishanarora04/quickxorhash/master/quickxorhash.js
|
|
||||||
|
|
||||||
let obj = {};
|
|
||||||
obj['modified'] = item.lastModifiedDateTime;
|
|
||||||
obj['name'] = item.name;
|
|
||||||
obj['size'] = item.size;
|
|
||||||
obj['hash'] = item.file?.hashes?.quickXorHash;
|
|
||||||
obj['path'] = Path.join(remotePath, item.name);
|
|
||||||
obj['url'] = item['@microsoft.graph.downloadUrl'];
|
|
||||||
|
|
||||||
array.push(obj);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
const res = await client.api(url).get();
|
||||||
|
const documents = res.value;
|
||||||
|
if (documents === undefined || documents.length === 0) {
|
||||||
|
GBLogEx.info(min, `${remotePath} is an empty folder.`);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Navigate files / directory to recurse.
|
||||||
|
|
||||||
|
await CollectionUtil.asyncForEach(documents, async item => {
|
||||||
|
|
||||||
|
if (item.folder) {
|
||||||
|
remotePath = urlJoin(remotePath, item.name);
|
||||||
|
array = [...array, ... await this.dirFolder({ pid, remotePath, baseUrl, client, array })];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// TODO: https://raw.githubusercontent.com/ishanarora04/quickxorhash/master/quickxorhash.js
|
||||||
|
|
||||||
|
let obj = {};
|
||||||
|
obj['modified'] = item.lastModifiedDateTime;
|
||||||
|
obj['name'] = item.name;
|
||||||
|
obj['size'] = item.size;
|
||||||
|
obj['hash'] = item.file?.hashes?.quickXorHash;
|
||||||
|
obj['path'] = Path.join(remotePath, item.name);
|
||||||
|
obj['url'] = item['@microsoft.graph.downloadUrl'];
|
||||||
|
|
||||||
|
array.push(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
const baseUrl = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}`;
|
const baseUrl = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}`;
|
||||||
min['cacheToken'] = { baseUrl, client };
|
min['cacheToken'] = { baseUrl, client };
|
||||||
|
|
||||||
return min['cacheToken'];
|
return { baseUrl, client };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue