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