new(basic.gblib): New SET WHOLE WORD keyword added.

This commit is contained in:
Rodrigo Rodriguez 2021-08-21 09:19:07 -03:00
parent eacd933b05
commit 88a63710c0
4 changed files with 61 additions and 41 deletions

View file

@ -343,6 +343,19 @@ export class DialogKeywords {
this.user = user; this.user = user;
} }
/**
* Defines the FIND behaviour to consider whole words while searching.
*
* @example SET WHOLE WORD ON
*
*/
public async setWholeWord(step, on) {
const user = await this.min.userProfile.get(step.context, {});
user.basicOptions.wholeWord = (on.trim() === "on");
await this.min.userProfile.set(step.context, user);
this.user = user;
}
/** /**
* Defines translator behaviour. * Defines translator behaviour.
* *

View file

@ -457,9 +457,20 @@ export class SystemKeywords {
case 'string': case 'string':
switch (filter.operator) { switch (filter.operator) {
case '=': case '=':
let wholeWord = true;
if (this.dk.user && this.dk.user.basicOptions && this.dk.user.basicOptions.wholeWord) {
wholeWord = this.dk.user.basicOptions.wholeWord;
}
if (wholeWord) {
if (result && result.toLowerCase().trim() === filter.value.toLowerCase().trim()) { if (result && result.toLowerCase().trim() === filter.value.toLowerCase().trim()) {
filterAcceptCount++; filterAcceptCount++;
} }
}
else {
if (result && result.toLowerCase().trim().indexOf(filter.value.toLowerCase().trim()) > -1) {
filterAcceptCount++;
}
}
break; break;
case 'not in': case 'not in':
if (filter.value.indexOf(result) === -1) { if (filter.value.indexOf(result) === -1) {

View file

@ -812,11 +812,14 @@ export class GBMinService {
const sec = new SecService(); const sec = new SecService();
if (!user.loaded) { if (!user.loaded) {
await min.conversationalService.sendEvent(min, step, 'loadInstance', {});
user.loaded = true; user.loaded = true;
user.subjects = []; user.subjects = [];
user.cb = undefined; user.cb = undefined;
user.welcomed = false; user.welcomed = false;
user.basicOptions = { maxLines: 100, translatorOn: true }; user.basicOptions = { maxLines: 100, translatorOn: true , wholeWord: true};
firstTime = true; firstTime = true;
@ -888,6 +891,7 @@ export class GBMinService {
// Answer to specific BOT Framework event conversationUpdate to auto start dialogs. // Answer to specific BOT Framework event conversationUpdate to auto start dialogs.
// Skips if the bot is talking. // Skips if the bot is talking.
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
if (context.activity.type === 'conversationUpdate' && if (context.activity.type === 'conversationUpdate' &&
context.activity.membersAdded.length > 0) { context.activity.membersAdded.length > 0) {
@ -906,19 +910,22 @@ export class GBMinService {
// Auto starts dialogs if any is specified. // Auto starts dialogs if any is specified.
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
if (!startDialog && !user.welcomed) { if (!startDialog && !user.welcomed) {
// Otherwise, calls / (root) to default welcome users. // Otherwise, calls / (root) to default welcome users.
await step.beginDialog('/'); await step.beginDialog('/');
} }
else {
user.welcomed = true;
GBLog.info(`Auto start (web) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`);
await GBVMService.callVM(startDialog.toLowerCase(), min, step, this.deployer);
}
} else { } else {
GBLog.info(`Person added to conversation: ${member.name}`); GBLog.info(`Person added to conversation: ${member.name}`);
if (this.userMobile(step) ) { if (this.userMobile(step) ) {
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
if (startDialog && !user.welcomed) { if (startDialog && !user.welcomed) {
user.welcomed = true; user.welcomed = true;
GBLog.info(`Auto start (whatsapp) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`); GBLog.info(`Auto start (whatsapp) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`);

View file

@ -77,6 +77,7 @@ class GBUIApp extends React.Component {
} }
send(command) { send(command) {
window.line window.line
.postActivity({ .postActivity({
type: 'event', type: 'event',
@ -86,6 +87,7 @@ class GBUIApp extends React.Component {
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
from: this.getUser() from: this.getUser()
}); });
} }
getUser() { getUser() {
@ -93,19 +95,6 @@ class GBUIApp extends React.Component {
return { id: 'web@gb', name: 'You' }; return { id: 'web@gb', name: 'You' };
} }
postEvent(name, item) {
setTimeout(() => {
window['botConnection'].postActivity({
type: "event",
name: name,
data: item,
locale: "en-us",
textFormat: "plain",
timestamp: new Date().toISOString(),
from: window.user
})
}, 400);
}
postMessage(value) { postMessage(value) {
window.line.postActivity({ window.line.postActivity({
type: 'message', type: 'message',
@ -198,7 +187,7 @@ class GBUIApp extends React.Component {
line.activity$ line.activity$
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance') .filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
.subscribe(() => { .subscribe(() => {
this.postEvent('startGB', true); _this_.send('startGB');
_this_.authenticate(); _this_.authenticate();
}); });