new (basic.gbapp): NOTE keyword.
This commit is contained in:
parent
527aa3af86
commit
8022980438
4 changed files with 40 additions and 49 deletions
|
@ -418,13 +418,7 @@ export class GBVMService extends GBService {
|
|||
|
||||
let code = min.sandBoxMap[text];
|
||||
const channel = step? step.context.activity.channelId : 'web';
|
||||
const pid = GBAdminService.getNumberIdentifier();
|
||||
GBServer.globals.processes[pid] = {
|
||||
pid: pid,
|
||||
userId: user? user.userId:0,
|
||||
instanceId: min.instance.instanceId,
|
||||
channel: channel
|
||||
};
|
||||
const pid = GBVMService.createProcessInfo(user, min, channel);
|
||||
const dk = new DialogKeywords();
|
||||
const sys = new SystemKeywords();
|
||||
await dk.setFilter ({pid: pid, value: null });
|
||||
|
@ -497,4 +491,15 @@ export class GBVMService extends GBService {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static createProcessInfo(user: GuaribasUser, min: GBMinInstance, channel: any) {
|
||||
const pid = GBAdminService.getNumberIdentifier();
|
||||
GBServer.globals.processes[pid] = {
|
||||
pid: pid,
|
||||
userId: user ? user.userId : 0,
|
||||
instanceId: min.instance.instanceId,
|
||||
channel: channel
|
||||
};
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -644,12 +644,7 @@ export class SystemKeywords {
|
|||
*
|
||||
*/
|
||||
public async note({ pid, text }): Promise<any> {
|
||||
const { min } = await DialogKeywords.getProcessInfo(pid);
|
||||
await this.internalNote(min,text );
|
||||
}
|
||||
|
||||
private async internalNote(min, text): Promise<any> {
|
||||
await this.internalSave(min, 'Notes.xlsx', [text]);
|
||||
await this.save({pid, file:"Notes.xlsx", args:[text]} );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -660,17 +655,6 @@ export class SystemKeywords {
|
|||
*/
|
||||
public async save({ pid, file, args }): Promise<any> {
|
||||
const { min } = await DialogKeywords.getProcessInfo(pid);
|
||||
await this.internalSave(min, file, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the content of several variables to a new row in a tabular file.
|
||||
*
|
||||
* @exaple SAVE "customers.xlsx", name, email, phone, address, city, state, country
|
||||
*
|
||||
*/
|
||||
|
||||
private async internalSave(min, file, args): Promise<any> {
|
||||
GBLog.info(`BASIC: Saving '${file}' (SAVE). Args: ${args.join(',')}.`);
|
||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||
const botId = min.instance.botId;
|
||||
|
|
|
@ -950,6 +950,7 @@ export class GBMinService {
|
|||
|
||||
const analytics = new AnalyticsService();
|
||||
const conversation = await analytics.createConversation(user);
|
||||
|
||||
}
|
||||
|
||||
await sec.updateConversationReferenceById(userId, conversationReference);
|
||||
|
@ -1058,8 +1059,10 @@ export class GBMinService {
|
|||
}
|
||||
} else if (context.activity.type === 'message') {
|
||||
// Processes messages activities.
|
||||
const pid = GBVMService.createProcessInfo(user, min, step.context.activity.channelId);
|
||||
step.context.activity['pid'] = pid;
|
||||
|
||||
await this.processMessageActivity(context, min, step);
|
||||
await this.processMessageActivity(context, min, step, pid);
|
||||
} else if (context.activity.type === 'event') {
|
||||
// Processes events activities.
|
||||
|
||||
|
@ -1249,7 +1252,7 @@ export class GBMinService {
|
|||
/**
|
||||
* Called to handle all text messages sent and received by the bot.
|
||||
*/
|
||||
private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) {
|
||||
private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep, pid) {
|
||||
const sec = new SecService();
|
||||
|
||||
if (!context.activity.text) {
|
||||
|
@ -1406,9 +1409,9 @@ export class GBMinService {
|
|||
step.context.activity['text'] = text;
|
||||
|
||||
const notes = min.core.getParam(min.instance, 'Notes', null);
|
||||
if (notes) {
|
||||
if (notes) {
|
||||
const sys = new SystemKeywords();
|
||||
await sys['internalNote'](min, text);
|
||||
await sys.note({pid, text});
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -106,14 +106,12 @@ export class AskDialog extends IGBDialog {
|
|||
|
||||
if (step.options && step.options.firstTime) {
|
||||
text = Messages[locale].ask_first_time;
|
||||
}
|
||||
else if (step.options && step.options.isReturning && !step.context.activity.group) {
|
||||
} else if (step.options && step.options.isReturning && !step.context.activity.group) {
|
||||
const askForMore = min.core.getParam(min.instance, 'Ask For More', null);
|
||||
|
||||
text = askForMore?Messages[locale].anything_else: '';
|
||||
}
|
||||
else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
|
||||
text = '';
|
||||
text = askForMore ? Messages[locale].anything_else : '';
|
||||
} else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
|
||||
return await step.next();
|
||||
} else if (user.subjects.length > 0) {
|
||||
text = Messages[locale].which_question;
|
||||
} else {
|
||||
|
@ -153,14 +151,18 @@ export class AskDialog extends IGBDialog {
|
|||
handled = true;
|
||||
}
|
||||
});
|
||||
data.step = null;
|
||||
GBLog.info(`/answer being called from getAskDialog.`);
|
||||
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
||||
data: data,
|
||||
query: text,
|
||||
user: user ? user['dataValues'] : null,
|
||||
message: text
|
||||
});
|
||||
if (!handled) {
|
||||
data.step = null;
|
||||
GBLog.info(`/answer being called from getAskDialog.`);
|
||||
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
||||
data: data,
|
||||
query: text,
|
||||
user: user ? user['dataValues'] : null,
|
||||
message: text
|
||||
});
|
||||
} else {
|
||||
return await step.next();
|
||||
}
|
||||
} else {
|
||||
return await step.next();
|
||||
}
|
||||
|
@ -339,8 +341,7 @@ export class AskDialog extends IGBDialog {
|
|||
const mainName = GBVMService.getMethodNameFromVBSFilename(text);
|
||||
await step.endDialog();
|
||||
return await GBVMService.callVM(mainName, min, step, user, this.deployer, false);
|
||||
}
|
||||
else if (text.startsWith('/')) {
|
||||
} else if (text.startsWith('/')) {
|
||||
return await step.replaceDialog(text, { answer: answer });
|
||||
} else {
|
||||
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
|
||||
|
@ -408,8 +409,8 @@ export class AskDialog extends IGBDialog {
|
|||
// Removes instructions, just code.
|
||||
|
||||
response = response.replace(/Copy code/gim, '\n');
|
||||
let lines = response.split('\n')
|
||||
let filteredLines = lines.filter(line => /\s*\d+\s*.*/.test(line))
|
||||
let lines = response.split('\n');
|
||||
let filteredLines = lines.filter(line => /\s*\d+\s*.*/.test(line));
|
||||
response = filteredLines.join('\n');
|
||||
|
||||
// Gets dialog name and file handling
|
||||
|
@ -428,7 +429,6 @@ export class AskDialog extends IGBDialog {
|
|||
message = `Dialog is ready! Let's run:`;
|
||||
await min.conversationalService.sendText(min, step, message);
|
||||
|
||||
|
||||
let sec = new SecService();
|
||||
const member = step.context.activity.from;
|
||||
const user = await sec.ensureUser(
|
||||
|
@ -443,8 +443,7 @@ export class AskDialog extends IGBDialog {
|
|||
|
||||
await step.endDialog();
|
||||
|
||||
await GBVMService.callVM(dialogName.toLowerCase(),
|
||||
min, step, user, this.deployer, false);
|
||||
await GBVMService.callVM(dialogName.toLowerCase(), min, step, user, this.deployer, false);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Add table
Reference in a new issue