fix(basic.gbapp): AS IMAGE testing.

This commit is contained in:
Rodrigo Rodriguez 2023-08-14 09:06:18 -03:00
parent 50a2dcbffc
commit d5bee8f721
3 changed files with 36 additions and 2 deletions

View file

@ -637,10 +637,18 @@ export class KeywordsExpressions {
];
keywords[i++] = [
/^\s*(.*)\=\s*(datediff)(\s*)(.*)/gim,
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*(datediff)(\s*)(.*)/gim,
($0, $1, $2, $3, $4) => {
const params = this.getParams($4, ['date1', 'date2', 'mode']);
return `await dk.getDateDiff ({pid: pid, ${params}})`;
return `${$1} = await dk.getDateDiff ({pid: pid, ${params}})`;
}
];
keywords[i++] = [
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*(user of)(\s*)(.*)/gim,
($0, $1, $2, $3, $4) => {
const params = this.getParams($4, ['username']);
return `${$1} = await sys.getUser ({pid: pid, ${params}})`;
}
];

View file

@ -62,6 +62,7 @@ import { KeywordsExpressions } from './KeywordsExpressions.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js';
import mime from 'mime-types';
import exts from '../../../extensions.json' assert { type: 'json' };
import { SecService } from '../../security.gbapp/services/SecService.js';
/**
* @fileoverview General Bots server core.
@ -464,6 +465,22 @@ export class SystemKeywords {
await min.conversationalService.sendMarkdownToMobile(min, null, mobile, message);
}
/**
* Get a user object from a alias.
*
* @example user = USER "someone"
*
*/
public async getUser({ pid, username }) {
const { min } = await DialogKeywords.getProcessInfo(pid);
let sec = new SecService();
const user = await sec.getUserFromUsername(min.instance.instanceId, username);
return {displayName: user.displayName,
mobile: user.userSystemId, email: user.email};
}
/**
* Sends a SMS message to the mobile number specified.
*

View file

@ -227,6 +227,15 @@ export class SecService extends GBService {
});
}
public async getUserFromUsername(instanceId: number, username: string): Promise<GuaribasUser> {
return await GuaribasUser.findOne({
where: {
instanceId: instanceId,
userName: username
}
});
}
/**
* Get a dynamic param from user. Dynamic params are defined in .gbdialog SET